#include <iostream>
using namespace std;
const int MAX = 505;
int a[MAX][MAX], res[MAX];
int n, m, q;
void calc(int i)
{
res[i] = 0;
int cnt = 0;
for (int j = 0; j <= m; j++)
if (a[i][j])
cnt++;
else
{
res[i] = max(res[i], cnt);
cnt = 0;
}
}
int main()
{
cin >> n >> m >> q;
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
cin >> a[i][j];
calc(i);
}
while (q--)
{
int x, y;
cin >> x >> y;
a[x - 1][y - 1] ^= 1;
calc(x - 1);
int ans = 0;
for (int i = 0; i < n; i++)
ans = max(ans, res[i]);
cout << ans << endl;
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwpjb25zdCBpbnQgTUFYID0gNTA1OwppbnQgYVtNQVhdW01BWF0sIHJlc1tNQVhdOwppbnQgbiwgbSwgcTsKdm9pZCBjYWxjKGludCBpKQp7CglyZXNbaV0gPSAwOwoJaW50IGNudCA9IDA7Cglmb3IgKGludCBqID0gMDsgaiA8PSBtOyBqKyspCgkJaWYgKGFbaV1bal0pCgkJCWNudCsrOwoJCWVsc2UKCQl7CgkJCXJlc1tpXSA9IG1heChyZXNbaV0sIGNudCk7CgkJCWNudCA9IDA7CgkJfQp9CmludCBtYWluKCkKewoJY2luID4+IG4gPj4gbSA+PiBxOwoJZm9yIChpbnQgaSA9IDA7IGkgPCBuOyBpKyspCgl7CgkJZm9yIChpbnQgaiA9IDA7IGogPCBtOyBqKyspCgkJCWNpbiA+PiBhW2ldW2pdOwoJCWNhbGMoaSk7Cgl9Cgl3aGlsZSAocS0tKQoJewoJCWludCB4LCB5OwoJCWNpbiA+PiB4ID4+IHk7CgkJYVt4IC0gMV1beSAtIDFdIF49IDE7CgkJY2FsYyh4IC0gMSk7CgkJaW50IGFucyA9IDA7CgkJZm9yIChpbnQgaSA9IDA7IGkgPCBuOyBpKyspCgkJCWFucyA9IG1heChhbnMsIHJlc1tpXSk7CgkJY291dCA8PCBhbnMgPDwgZW5kbDsKCX0KCXJldHVybiAwOwp9Cg==