#include <bits/stdc++.h>

// limit
#define mod1 22439423LL
#define mod2 42342432LL
#define mod3 56454765LL
#define mod4 66867574LL
#define oo 1000000001
#define OO 1000000000000000007LL
#define maxN 107

// loop
#define fto(i, x, y) for(int i = (x); i <= (y); ++i)
#define fdto(i, x, y) for(int i = (x); i >= (y); --i)
#define ftoa(i, x, y, a) for(int i = (x); i <= (y); i += a)
#define fdtoa(i, x, y, a) for(int i = (x); i >= (y); i -= a)
#define ftosqrt(i, x, y) for(int i = (x); i*i <= (y); ++i)
#define ftoit(it, var) for (__typeof(var.begin()) it = var.begin(); it != var.end(); ++it)
#define fdtoit(rit, var) for (__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); ++rit)

// debug
#define debug cout << "*" << endl;
#define bug1d(a, x, y) { cout << #a << ": "; fto(_, x, y) cout << a[_] << ' '; cout << endl; }
#define bug2d(a, x, y, u, v) { cout << #a << ": " << endl; fto(i, x, y) {fto(j, u, v) cout << a[i][j] << ' '; cout << endl;}; cout << endl;}
#define bug(a) cout << #a << " = " << a << endl;
#define bug2(a, b) cout << #a << " = " << a << "; "; cout << #b << " = " << b << endl;
#define bug3(a, b, c) cout << #a << " = " << a << "; "; cout << #b << " = " << b << "; "; cout << #c << " = " << c << endl;

// operation
#define mp make_pair
#define pb push_back
#define pf push_front
// structure
#define ii pair<int, int>
#define iii pair<ii, int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>
#define matrix vector<vi>

// get value
#define FF first
#define SS second

// data type
#define ll long long
#define ull unsigned long long

// function
#define lb lower_bound
#define ub upper_bound

// const value
#define pi 3.14159265358979323846264338327950288419716939937510

using namespace std;

template <class T>
T min(T a, T b, T c) {
    return min(a, min(b, c));
}

template <class T>
T min(T a, T b, T c, T d) {
    return min(a, min(b, min(c, d)));
}

template <class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

template <class T>
T max(T a, T b, T c, T d) {
    return max(a, max(b, max(c, d)));
}

bool cmp(const ii& a, const ii& b) {return (a.FF > b.FF || (a.FF == b.FF && a.SS >= b.SS));}
ll GCD(ll a, ll b) {return (a%b) ? GCD(b, a%b) : b;}

const string namePro = "rect";

int n, m, k;
int h[maxN], w[maxN];

bool isCheck[maxN][maxN];
int ans, res, cnt_fill, cnt_check;

ii trace[maxN], bestTrace[maxN];

bool inBound(int type, int x, int y) {
	fto (i, x, x+h[type]-1) {
		fto (j, y, y+w[type]-1) {
            ++cnt_check;
			if (isCheck[i][j]) return 0;
		}
	}
	return 1;
}

void check(int type, int x, int y) {
	fto (i, x, x+h[type]-1) {
		fto (j, y, y+w[type]-1) {
		    ++cnt_fill;
			isCheck[i][j] = 1;
		}
	}
	return;
}

void uncheck(int type, int x, int y) {
	fto (i, x, x+h[type]-1) {
		fto (j, y, y+w[type]-1) {
		    ++cnt_fill;
			isCheck[i][j] = 0;
		}
	}
	return;
}

void brute_force(int x) {
	if (x > k) {
		if (ans < res) {
			ans = res;
//			int cnt = 0;
			fto (i, 1, k) {
//			    if (trace[i] != mp(0, 0)) ++cnt;
			    bestTrace[i] = trace[i];
			}
//			if (cnt != res) {
//                fto (i, 1, k) cout << trace[i].FF << " " << trace[i].SS << endl;
//                exit(0);
//			}
		}

		return;
	}

	if (ans == k) return;
	fto (i, 1, n-h[x]+1) {
		fto (j, 1, m-w[x]+1) {
			bool tmp = inBound(x, i, j);
			if (tmp) check(x, i, j);

			if (tmp) ++res;
			if (tmp) trace[x] = mp(i, j);

			if (tmp) brute_force(x+1);
			trace[x] = mp(0, 0);

			if (tmp) uncheck(x, i, j);
			if (tmp) --res;
		}
	}

	brute_force(x+1);
	return;
}


int main() {
    #ifndef ONLINE_JUDGE
        freopen((namePro+".inp").c_str(), "r", stdin);
        freopen((namePro+".out").c_str(), "w", stdout);
    #endif // ONLINE_JUDGE

    scanf("%d%d%d", &n, &m, &k);
    fto (i, 1, k) scanf("%d%d", &h[i], &w[i]);

	brute_force(1);
	//cout << ans << endl;

    //cout << cnt_fill << " " << cnt_check << endl;

	printf("%d\n", k);
	fto (i, 1, k) printf("%d %d\n", bestTrace[i].FF, bestTrace[i].SS);

    return 0;
}
