```cpp
// Author:PanDaoxi
#include <bits/stdc++.h>
using namespace std;
const int inf = 5;
int n, m, t, ans, sx, sy, ex, ey,
fx[5] = {0, -1, 1, 0, 0},
fy[5] = {0, 0, 0, -1, 1};
bool a[inf][inf];
void dfs(int x, int y, int k=0){
if(x == ex && y == ey){
ans++;
return;
}
a[x][y] = true;
for(int i=1; i<=4; i++){
int xx = x + fx[i], yy = y + fy[i];
if(xx >= 1 && xx <= n && yy >= 1 && yy <= m && !a[xx][yy]){
dfs(xx, yy, k+1);
a[xx][yy] = false;
}
}
}
int main(){
cin >> n >> m >> t >> sx >> sy >> ex >> ey;
for(int i=1; i<=t; i++){
int p, q;
cin >> p >> q;
a[p][q] = true;
}
dfs(sx, sy);
cout << ans;
return 0;
}
```
by PanDaoxi @ 2022-11-18 22:10:32