#include<bits/stdc++.h>
using namespace std;
const int N=6e5+10,M=N*300;
int ls[M],rs[M],nx[M],tt;
inline int NEW(int p)
{
++tt;ls[tt]=ls[p],rs[tt]=rs[p],nx[tt]=nx[p];
return tt;
}
int mdf(int t,int l,int r,int k,int v)
{
int p=NEW(t);
if(l==r)return nx[p]=v,p;
int mid=l+r>>1;
if(k<=mid)ls[p]=mdf(ls[p],l,mid,k,v);
else rs[p]=mdf(rs[p],mid+1,r,k,v);
return p;
}
int ask(int p,int l,int r,int k)
{
if(l==r)return nx[p];int mid=l+r>>1;
if(k<=mid)return ask(ls[p],l,mid,k);
else return ask(rs[p],mid+1,r,k);
}
int n,m;
//map<pair<int,int>,int>V;
namespace ACAM
{
// vector<int>W[N];
int rt[N],fa[N],tt,val[N],edp[N],ban[N];
int dep[N],ff[N];
map<int,int>tr[N];
void ins(vector<int>X,int x)
{
int u=0,C=0;
for(int k:X)
{
int x=u;
u=tr[u][k]?tr[u][k]:(tr[u][k]=++tt);
dep[u]=++C;edp[u]=k;//ff[u]=x;
}
if(!x)ban[u]=1;else val[u]=x;
}
int getnxt(int u,int f)
{
while(u&&!tr[u].count(f))u=fa[u];
return tr[u][f];
}
void build()
{
static int q[N];
int l=1,r=0;
for(auto k:tr[0])q[++r]=k.second,rt[0]=mdf(rt[0],1,n,k.first,k.second);
while(l<=r)
{
int u=q[l++];
int z=rt[fa[u]];
for(auto k:tr[u])
{
fa[k.second]=ask(z,1,n,k.first);
assert(fa[k.second]==getnxt(fa[u],k.first));
z=mdf(z,1,n,k.first,k.second);
q[++r]=k.second;
}
for(int i=1;i<=n;++i)assert(ask(z,1,n,i)==getnxt(u,i));
rt[u]=z;
}
for(int i=1,u;u=q[i],i<=r;++i)
{
ban[u]|=ban[fa[u]];
// assert(!!val[u]+!!val[fa[u]]<=1);
val[u]+=val[fa[u]];
// assert((val[u]==V[pair<int,int>{edp[ff[u]],edp[u]}]));
// cerr<<u<<": "<<val[u]<<endl;
}
}
}
int k;
long long dis[M];
int via[M],W[N];
int main()
{
cin>>n>>m>>k;
vector<pair<int,int>>Z;
for(int i=1,u,v,w;i<=m;++i)
{
cin>>u>>v>>w,ACAM::ins({u,v},w);
if(u==1)Z.emplace_back(v,w);//V[pair<int,int>{u,v}]=w;
}
for(int i=1;i<=k;++i)
{
vector<int>Z;int p;cin>>p;Z.resize(p);
for(int i=0;i<p;++i)cin>>Z[i];ACAM::ins(Z,0);
}
ACAM::build();
memset(dis,0x3f,sizeof dis);
priority_queue<pair<long long,int>>Q;
int c=0;
if(!ACAM::tr[0][1])return puts("-1"),0;
int x=ACAM::tr[0][1];
dis[x]=0;Q.emplace(0,x);
long long ans=1e18;
auto jud=[&](int x,long long d){if(dis[x]>d)dis[x]=d,Q.emplace(-dis[x],x);};
while(!Q.empty())
{
auto k=Q.top();Q.pop();
int u=k.second;
// cerr<<u<<" "<<ACAM::dep[u]<<" "<<c<<" "<<ACAM::ban[u]<<endl;
if(u<=ACAM::tt&&ACAM::dep[u]<=1&&c)continue;
if(u<=ACAM::tt&&ACAM::ban[u])continue;
if(via[u])continue;via[u]=1;c=1;
// cerr<<u<<" "<<ACAM::tt<<" "<<dis[u]<<endl;
if(u<=ACAM::tt)
{
// cerr<<u<<" "<<ACAM::tt<<" "<<dis[u]<<endl;
long long l=(dis[u]+=ACAM::val[u]);
if(ACAM::edp[u]==n)ans=min(ans,l);
if(ACAM::rt[u])jud(ACAM::rt[u]+ACAM::tt,l);
}
else
{
long long l=dis[u];
u-=ACAM::tt;
if(ls[u])jud(ACAM::tt+ls[u],l);
if(rs[u])jud(ACAM::tt+rs[u],l);
if(nx[u])jud(nx[u],l);//,cerr<<"FOUND: "<<nx[u]<<" "<<ACAM::dep[nx[u]]<<endl;
}
}
if(ans>=1e18)return puts("-1"),0;
cout<<ans<<endl;
}