include[HTML_REMOVED]
using namespace std;
const int N = 100010;
typedef long long ll;
ll res1, res2;
int row[N], col[N], tmp[N];
int main () {
int n, m, c;
cin >> n >> m >> c;
for(int i = 0, x, y; i < c; i ){
cin >> x >> y;
row[x] ;
col[y] ;
}
if(c % n == 0){
int rowi = c / n;
int x1;
for(int i = 2 ; i <= n ; i)
tmp[i] = tmp[i-1] + rowi - row[i];
sort(tmp + 1, tmp + n + 1);
if(n % 2 == 0) x1 = ( tmp[ n / 2 ] + tmp[ n / 2 + 1 ] ) / 2;
else x1 = tmp[ n / 2];
for(int i = 1; i <= n; i )
res1 += abs( x1 - tmp[i] );
}
if(c % m == 0){
int coli = c / m;
int x1 = 0;
for(int i = 1; i <= m; i )
tmp[i] = tmp[ i - 1 ] + coli - col[i];
sort(tmp + 1, tmp + m + 1);
if(m % 2 == 0) x1 = (tmp[ m / 2 ] + tmp[ m / 2 + 1]) / 2;
else x1 = tmp[ m / 2 ];
for(int i = 1; i <= m; i ++)
res2 += abs(x1 - tmp[i]);
}
if(res1 && res2) cout << “both ” << res1 + res2;
else if(res1) cout << “row ” << res1;
else if(res2) cout << “column ” << res2;
else cout << “impossible”;
return 0;
}