// Problem: D - Shipping Center
// Contest: AtCoder - Panasonic Programming Contest (AtCoder Beginner Contest 195)
// URL: https://atcoder.jp/contests/abc195/tasks/abc195_d
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Parsed on: 13-03-2021 18:36:40 IST (UTC+05:30)
// Author: Kapil Choudhary
// ********************************************************************
// कर्मण्येवाधिकारस्ते मा फलेषु कदाचन |
// मा कर्मफलहेतुर्भूर्मा ते सङ्गोऽस्त्वकर्मणि || १.४७ ||
// ********************************************************************

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define PI 3.1415926535897932384626
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << ", " << #y << "=" << y << endl
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int>	vi;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pii>	vpii;
typedef vector<pll>	vpll;
typedef vector<vi> vvi;
typedef vector<vll>	vvll;
typedef vector<vull> vvull;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
    uniform_int_distribution<int> uid(0,lim-1);
    return uid(rang);
}

const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;

void solve()
{
  	int n, m, q;
  	cin >> n >> m >> q;
  	
  	vpii v(n);
  	for(int i = 0; i < n; i++) {
  		cin >> v[i].F >> v[i].S;
  	}
  	
  	vi t(m);
  	for(int i = 0; i < m; i++) cin >> t[i];
  	
  	//cout << n << " " << m << " " << q << endl;
  	//for(auto x: v) cout << x.F << " " << x.S << endl;
  	//for(auto x: t) cout << x << " "; cout << endl;
  	
  	while(q--) {
  		int L, R; cin >> L >> R;
  		L -= 1, R -= 1;
  		//deb2(L, R);
  		vi boxes;
  		for(int i = 0; i < L; i++) boxes.pb(t[i]);
  		for(int i = R + 1; i < m; i++) boxes.pb(t[i]);
  		
  		//for(auto x: boxes) cout << x << " "; cout << endl;
  		
  		sort(boxes.begin(), boxes.end());
  		
  		vector<bool> taken(n, 0);
  		
  		ll mx = 0LL;
  		for(int i = 0; i < (int)boxes.size(); i++) {
  			int idx = -1;
  			ll tmp = LLONG_MIN;
  			for(int j = 0; j < n; j++) {
  				if(!taken[j] and v[j].F <= boxes[i]) {
  					if(tmp < v[j].S) {
  						tmp = v[j].S;
  						idx = j;
  					}
  				}
  			}
  			
  			if(tmp != LLONG_MIN) {
  				mx += tmp;
  				taken[idx] = 1;
  			}
  		}
  		
  		cout << mx << "\n"; 
  	}
}

int main()
{
    ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif

    int t = 1;
    // cin >> t;
    while(t--) {
      solve();
    }

    return 0;
}
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define rrep(i, a, b) for (int i = (a); i >= (b); --i)
#define PB push_back
#define ar2 array<int, 2>
typedef long long LL;
const LL P = 1e9 + 7;
const LL INF = 1e9;
const int N = 2e5 + 5;
mt19937 rng(time(0));

int T, n, m;
char s1[N], s2[N], s3[N], res[N];

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    cin >> T;
    rep(cas, 1, T) {
        cin >> n;
        cin >> (s1 + 1) >> (s2 + 1) >> (s3 + 1);
        int j = 0;
        rep(i, 1, (n + 1) / 2) res[++j] = '0';
        rep(i, 1, n) res[++j] = '1';
        rep(i, 1, n / 2 + 1) res[++j] = '0';
        res[++j] = 0;
        cout << (res + 1) << endl;
    }
    return 0;
}
