// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

const int N = 305, T = 2e5 + 5;

int L[N], ava[N], need[N][N], has[N][N], a[T], b[T];

bool done[N];

int got[N];

int main() {

	int p, r, t;

	scanf("%d%d%d", &p, &r, &t);

	for (int i = 1; i <= r; ++ i) scanf("%d", &L[i]);

	for (int i = 1; i <= p; ++ i) {

		for (int j = 1; j <= r; ++ j) scanf("%d", &need[i][j]);

	}

	for (int i = 1; i <= t; ++ i) scanf("%d%d", &a[i], &b[i]);

	int l = 1, R = t, ans = -1;

	while (l <= R) {

		int mid = (l + R) / 2;

		memset(has, 0, sizeof(has));

		memset(ava, 0, sizeof(ava));

		memset(got, 0, sizeof(got));

		memset(done, 0, sizeof(done));

		for (int i = 1; i <= r; ++ i) ava[i] = L[i];

		int dones = 0;

		for (int i = 1; i <= p; ++ i) {

			for (int j = 1; j <= r; ++ j) if (need[i][j] == 0) {

				got[i] ++;

				if (got[i] == r) {

					done[i] = 1;

					dones ++;

				}

			}

		}

		for (int i = 1; i <= mid; ++ i) {

			has[a[i]][b[i]] ++;

			ava[b[i]] --;

			if (has[a[i]][b[i]] == need[a[i]][b[i]]) {

				got[a[i]] ++;

				if (got[a[i]] == r) {

					done[a[i]] = 1;

					dones ++;

					for (int j = 1; j <= r; ++ j) ava[j] += need[a[i]][j];

				}

			}

		}

		bool flag = 1;

		while (flag) {

			flag = 0;

			for (int i = 1; i <= p; ++ i) {

				if (done[i]) continue;

				bool can = 1;

				for (int j = 1; j <= r; ++ j) if (ava[j] + has[i][j] < need[i][j]) {

					can = 0;

					break;

				}

				if (can) {

					done[i] = 1;

					dones ++;

					flag = 1;

					for (int j = 1; j <= r; ++ j) ava[j] += has[i][j];

				}

			}

		}

		if (dones == p) {

			l = mid + 1;

		}

		else {

			R = mid - 1;

			ans = mid;

		}

	}

	printf("%d\n", ans);

}

// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

#define fi first

#define se second

#define mp make_pair

using namespace std;



typedef pair <int, int> pii;



int p, r, t;

int l[310], nl[310];

int n[310][310], nn[310][310];

pii a[200010];

int cnt[310];



bool check(int mid){

	for (int i = 1; i <= r; i++){

		nl[i] = l[i];

	}

	for (int i = 1; i <= p; i++){

		cnt[i] = 0;

		for (int j = 1; j <= r; j++){

			nn[i][j] = n[i][j], cnt[i] += n[i][j];

		}

	}

	for (int i = 0; i <= mid; i++){

		int P = a[i].fi, R = a[i].se;

		nl[R]--, nn[P][R]--, cnt[P]--;

		if (cnt[P] == 0){

			for (int j = 1; j <= r; j++){

				nl[j] += n[P][j];

			}

		}

	}

	int pd = 1;

	while (pd){

		pd = 0;

		for (int i = 1; i <= p; i++){

			int flag = 1, ppp = 1;

			for (int j = 1; j <= r; j++){

				if (nl[j] < nn[i][j]){

					flag = 0;

					break;

				}

				if (nn[i][j]) ppp = 0;

			}

			if (!flag || ppp) continue;

			for (int j = 1; j <= r; j++){

				nl[j] += n[i][j] - nn[i][j];

				nn[i][j] = 0;

			}

			pd = 1;

		}

	}

	for (int i = 1; i <= p; i++){

		for (int j = 1; j <= r; j++){

			if (nn[i][j]) return 1;

		}

	}

	return 0;

}



int main(){

	scanf("%d%d%d", &p, &r, &t);

	for (int i = 1; i <= r; i++){

		scanf("%d", &l[i]);

	}

	for (int i = 1; i <= p; i++){

		for (int j = 1; j <= r; j++){

			scanf("%d", &n[i][j]);

		}

	}

	for (int i = 0; i < t; i++){

		scanf("%d%d", &a[i].fi, &a[i].se);

	}

	if (!check(t - 1)){

		printf("-1\n");

		return 0;

	}

	int l = 0, r = t - 1;

	while (l < r){

		int mid = l + r >> 1;

		if (!check(mid)) l = mid + 1;

		else r = mid;

	}

	printf("%d\n", l + 1);

	return 0;

}




// Fastest known solution for this problem: