#include <bits/stdc++.h>
using namespace std;
int n, m, t, sx, sy, zx, zy, ax, ay, ans, dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0}, v[1000][1000],q[1000][1000];
void dfs(int x, int y) {
cout << x << " " << y << endl;
if (x == zx && y == zy) {
ans++;
cout << endl;
return;
}
for (int i = 0; i < 4; i++) {
int nx = x + dx[i], ny = y + dy[i];
if (nx >= 1 && ny >= 1 && nx <= n && ny <= m && q[nx][ny] == 0 && v[nx][ny] == 0) {
v[nx][ny] = 1;
dfs(nx, ny);
v[nx][ny] = 0;
}
}
}
int main() {
cin >> n >> m >> t;
cin >> sx >> sy >> zx >> zy;
for (int i = 0; i < t; i++) {
cin >> ax >> ay;
q[ax][ay] = 1;
}
dfs(sx, sy);
cout << ans;
return 0;
}