#include<stdio.h>
main()
{

	int d[20],u[20],n=3,m=4,x[20],l[20],r[20],i,k,b,max,min,p;
	
	printf("Unesi broj vagi:");
	scanf("%d",&n);
	printf("Unesi broj pitanja:");
	scanf("%d",&m);
	
	for(i=0;i<n;i++)
	{
		printf("Unesi donju granicu:");
		scanf("%d",&d[i]);
		printf("Unesi gornju granicu:");
		scanf("%d",&u[i]);
			
	}
	
	for(i=0;i<m;i++)
	{
		printf("Unesi indeks:");
		scanf("%d",&l[i]);
		printf("Unesi indeks:");
		scanf("%d",&r[i]);
		printf("Unesi kilazu:");
		scanf("%d",&x[i]);			
	}	
	
	for(i=0;i<m;i++)
	{

		for(k=l[i],p=0;k<=r[i];k++)
		if(d[k]<=x[i] && x[i]<=u[k])
		p++;
		
		printf("\n%d",p);
	}
	
}