Please help me out, below is the code.. I am trying from last 5 days 
#include<iostream>
#include<map>
using namespace std;
int main()
{
map<long long, long long> v;
int lo;
long long t,n,r,i,c,z,temp;
cin>>t;
temp = 1;
while(t--)
{
lo = 0;
cin>>n>>r;
for(z=1;z<=r;z++)
{
cin>>i>>c;
if(v[i] == c)
lo = 1;
else
{
v[i] = c;
}
}
if(lo == 0)
cout<<"Scenario #"<<temp<<": possible\n";
else
cout<<"Scenario #"<<temp<<": impossible\n";
temp++;
}
return 0;
}