#include //eolibraries #define lnf 3999999999999999999 #define inf 999999999 #define fi first #define se second #define pb push_back #define all(c) (c).begin(),(c).end() #define sz(c) (int)(c).size() #define make_unique(a) sort(all(a)),a.erase(unique(all(a)),a.end()); #define rep(i,n) for(int i=0;i=0;i--) #define crep(i,x,n) for(int i=x;i #define _3ioVv0Q ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0) //eodefine using namespace std; typedef long long i64; typedef long double ld; using pii=pair; using tpii=pair; using vi=vec(i64); const int mxn=12000; int min(int o,int w){ if(o>n>>m>>q; vec(vi) rbts(n); rep(_,q){ int u,v; cin>>u>>v; u--,v--; rbts[u].pb(v); } rep(i,n){ sort(all(rbts[i])); } vec(vi) dp(n,vi(n+2,inf)); rep(i,n){ if(i) dp[i]=dp[i-1]; if(sz(rbts[i])){ int v=rbts[i][0]; dp[i][1]=min(dp[i][1],v); } if(i){ rep(j,n+1){ int v=dp[i-1][j]; if(v==inf) continue; auto it=upper_bound(all(rbts[i]),v); if(it==rbts[i].end()) continue; dp[i][j+1]=min(dp[i][j+1],*it); } } } drep(j,n+1){ if(dp[n-1][j]!=inf){ cout<