import std.stdio;
import std.algorithm;
import std.string;
import std.range;
import std.array;
import std.conv;
import std.complex;
import std.math;
import std.ascii;
import std.bigint;
import std.container;
import std.typecons;

auto readInt() {
	return readInts()[0];
}
auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readLong() { 
	return readLongs()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}

int rScore(int[] r) {
	int ans;
	int tmp;
	foreach(i; 0..r.length) {
		if(r[i] == 1) {
			++tmp;
		} else {
			ans = max(ans, tmp);
			tmp = 0;
		}
	}
	return max(tmp, ans);
}
void main() {
	auto l = readInts();
	auto n = l[0];
	auto m = l[1];
	auto q = l[2];
	int[][] b;
	foreach(i; 0..n) {
		b ~= readInts();
	}
	int[] rs;
	foreach(i; 0..n) {
		rs ~= rScore(b[i]);
	}
	foreach(k; 0..q) {
		auto ij = readInts();
		auto i = ij[0]-1;
		auto j = ij[1]-1;
		b[i][j] ^= 1;
		rs[i] = rScore(b[i]);
		writeln(reduce!(max)(rs));
	}
}






