#include<bits/stdc++.h>
using namespace std;
#define io cin.tie(0);ios::sync_with_stdio(false);
#define debug(x) cout<<#x<<"="<<x<<endl
#define lowbit(x) x&(-x)
#define pii pair<int,int>
#define mk make_pair
#define ll long long
#define rs p<<1|1
#define ls p<<1
const int maxn = 2005;
const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
inline ll read(){
    ll p=0,f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){p=(p<<1)+(p<<3)+(c^48),c=getchar();}
    return f*p;
}

int dis1[maxn][maxn], dis2[maxn][maxn], vis[maxn];
struct node{
    int u, w;
    bool operator < (const node &a) const{
        return w > a.w;
    }
};
vector<node> v1[maxn], v2[maxn];
void dij1(int st){
    dis1[st][st] = 0;
    queue<node> q;
    q.push({st, 0});
    while(q.size()){
        node t = q.front(); q.pop();
        int from = t.u;
        for(auto it : v1[from]){
            int to = it.u, w = it.w;
            if(dis1[st][from] + w < dis1[st][to]){
                dis1[st][to] = dis1[st][from] + w;
                q.push({to, dis1[st][to]});
            }
        }
    }
}
void dij2(int st){
    dis2[st][st] = 0;
    queue<node> q;
    q.push({st, 0});
    while(q.size()){
        node t = q.front(); q.pop();
        int from = t.u;
        for(auto it : v2[from]){
            int to = it.u, w = it.w;
            if(dis2[from][st] + w < dis2[to][st]){
                dis2[to][st] = dis2[from][st] + w;
                q.push({to, dis2[to][st]});
            }
        }
    }
}
void solve(){
    int n, m;
    scanf("%d%d", &n, &m);
    fill(vis, vis + maxn, inf);
    for(int i = 1; i <= m; i ++){
        int x, y, w;
        scanf("%d%d%d", &x, &y, &w);
        if(x == y){
            vis[x] = min(vis[x], w);
            continue;
        }
        v1[x].push_back({y, w});
        v2[y].push_back({x, w});
    }
    memset(dis1, inf, sizeof dis1);
    memset(dis2, inf, sizeof dis2);
    for(int i = 1; i <= n; i ++){
        dij1(i);
        dij2(i);
    }
    for(int i = 1; i <= n; i ++){
        int ans = inf;
        for(int j = 1; j <= n; j ++){
            if(i == j) continue;
            ans = min(ans, dis1[i][j] + dis2[j][i]);
        }
        ans = min(ans, vis[i]);
        if(ans == inf) ans = -1;
        printf("%d\n", ans);
    }
}
int main(){
    solve();
    return 0;
}
#include <bits/stdc++.h>
//#include <cmath>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define mod 1000000007
//#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second
#define bs(yup,x) binary_search(yup.begin(),yup.end(),x) //it will return bollean value
#define lb(yup,x) lower_bound(yup.begin(),yup.end(),x)  //it will return the adress of the number which is equal to or just greater than x ,and if it is equal to yup.end() than their in no such number exist
#define ub(yup,x) upper_bound(yup.begin(),yup.end(),x)
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
using namespace std;
const long long N=200005, INF=2000000000000000000;
const long double EPS= 0.000000000001;
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }
vi prime;
bool isprime[N];
void pre()
{
    for(int i=2;i<N;i++)
    {
        if(isprime[i])
        {
            for(int j=i*i;j<N;j+=i)
            isprime[j]=false;
            prime.pb(i);
        }
    }
    return;
}



int32_t main()
{
    
    IOS;
    //fill(isprime, true);
    //pre();
    int t=1;
    //cin>>t;
    while(t--)
    {
        int n,m,q;
        cin>>n>>m>>q;
        pair<int ,int> a[n];
        rep(i,0,n) cin>>a[i].ss>>a[i].ff;
        sort(a,a+n,greater< pii >());
        int b[m+1];
        rep(i,1,m+1) cin>>b[i];
        while(q--)
        {
            int l,r,ans=0;
            cin>>l>>r;
            set<int>s;
            vi v;
            rep(i,1,l) v.pb(b[i]);
            rep(i,r+1,m+1) v.pb(b[i]);
            sort(all(v));
            for(int i=0;i<n;i++)
            {
                auto pos=lower_bound(all(v),a[i].ss);
                if(pos!=v.end())
                {
                    ans+=a[i].ff;
                    v.erase(pos);
                }
            }
            cout<<ans<<"\n";
        }
    }

}











