#include using namespace std; #include #include #include #include #include template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } #define rep(i,n) for (int i = 0; i < (n); ++i) typedef long long ll; typedef long double ld; typedef unsigned long long ull; using P=pair; const int INF=1001001001; const int mod=1e9+7; void solve(){ int n,m,q; cin>>n>>m>>q; vector

p(q+1); for(int i=1;i<=q;i++)cin>>p[i].first>>p[i].second; vectordp(n+1,-INF); dp[0]=0; for(int i=1;i<=q;i++){ for(int j=i-1;j>=0;j--){ if(dp[j] != -INF && p[j].second < p[i].second && p[j].first < p[i].first){ chmax(dp[i],dp[j]+1); } } } int ans=0; rep(i,q+1){ chmax(ans,dp[i]); } cout<