#include <iostream>
#include <vector>
#include <cstdio>
using namespace std ;

const int MAXN = 5e5 + 8 ;


int n , q , l , r , k ;

int mx = 1 ;


int main()
{
	freopen( "query.in" , "r" , stdin ) ;
	freopen( "query.out" , "w" , stdout ) ;
	

	
	cin >> n ;
	for ( int i = 1 , u , v ; i <= n ; i++ )
	{
		cin >> u >> v ;
		
	}
	
	
	cin >> q ;
	while ( q-- )
	{
		cin >> l >> r >> k ;
		
		mx = 1 ;
		
		cout << mx << endl ;
	}
	
	fclose( stdin ) ;
	fclose( stdout ) ;
	
	return 0 ;
} 
