#include using namespace std; typedef long long ll; int read(){ int x=0; bool f=1; char c=getchar(); while(c<48||c>57) f^=(c==45), c=getchar(); while(c>=48&&c<=57) x=x*10+(c&15), c=getchar(); return f?x:-x; } const int N=100105; const ll P=1000000007; int n; array e[N]; ll l, v, t[N], f[N]; ll fpow(ll a, ll b){ ll r=1; for(; b; b>>=1, a=a*a%P) if(b&1) r=r*a%P; return r; } int main(){ freopen("assign.in", "r", stdin); freopen("assign.out", "w", stdout); for(int _=read(); _; _--){ l=read(), n=read(), v=read(); for(int i=1; i<=n; i++){ int c=read(), d=read(); e[i]={c, d}; } if(v==1){puts("1"); continue; } sort(e+1, e+n+1); bool F=1; for(int i=1; F&&i