#include <bits/stdc++.h>
using namespace std;
const int size= 1e4 ;
struct edge
{
int to;
edge * nxt;
} ;
struct ver
{
int head;
edge * firsteg;
} ;
int vis[ 10000 ] ;
class alg
{
private :
ver hd[ size] ;
int vernum;
int egnum;
public :
alg ( int a[ ] , int n, int e)
{
edge * bt= nullptr ;
vernum= n;
egnum= e;
for ( int i= 0 ; i< vernum; i++ )
{
hd[ i] . head= a[ i] ;
hd[ i] . firsteg= nullptr ;
}
int from, to;
for ( int k= 0 ; k< e; k++ )
{
cin>> from>> to;
bt= new edge;
bt- > to= to;
bt- > nxt= hd[ from] . firsteg;
hd[ from] . firsteg= bt;
}
}
~ alg ( )
{
edge * p= nullptr ;
edge * q= nullptr ;
for ( int i= 0 ; i< vernum; i++ )
{
p= q= hd[ i] . firsteg;
while ( p!= nullptr )
{
p= p- > nxt;
delete q;
q= p;
}
}
}
void bfs ( int u)
{
int q[ 1000 ] ;
int fr= - 1 , rear= - 1 ;
q[ ++ rear] = u;
vis[ u] = 1 ;
edge * bt= nullptr ;
cout<< hd[ u] . head<< endl;
int w;
int v;
while ( fr!= rear)
{
w= q[ ++ fr] ;
cout<< hd[ w] . head<< endl;
bt= hd[ w] . firsteg;
while ( bt!= nullptr )
{
v= bt- > to;
if ( ! vis[ v] )
{
cout<< hd[ v] . head<< endl;
q[ ++ rear] = v;
}
bt= bt- > nxt;
}
}
}
int j;
void dfs ( int u)
{
edge * bt= nullptr ;
cout<< hd[ u] . head<< endl;
vis[ u] = 1 ;
bt= hd[ u] . firsteg;
while ( bt!= nullptr )
{
j= bt- > to;
if ( vis[ j] != 1 )
dfs ( j) ;
bt= bt- > nxt;
}
}
} ;
#include <bits/stdc++.h>
using namespace std;
const int hash_size= 1e4 ;
queue< int > q;
struct node
{
int to, nxt, val;
} mp[ hash_size] ;
int head[ hash_size] ;
int top;
void pre ( )
{
memset ( head, - 1 , sizeof head) ;
}
void add ( int from, int to, int value)
{
mp[ top] . to= to;
mp[ top] . nxt= head[ from] ;
mp[ top] . val= value;
head[ from] = top++ ;
}
void bianli ( int from)
{
cout<< from<< endl;
for ( int i= head[ from] ; ~ i; i= mp[ i] . nxt)
{
cout<< mp[ i] . to<< " " << mp[ i] . val<< endl;
}
}
void dfs ( int u, int v)
{
cout<< u<< endl;
for ( int i= head[ u] ; ~ i; i= mp[ i] . nxt)
{
if ( mp[ i] . to!= v)
{
cout<< mp[ i] . to<< " " << mp[ i] . val<< endl;
dfs ( v, u) ;
}
}
}
struct haxi
{
int head[ hash_size] ;
int to[ hash_size] ;
int nxt[ hash_size] ;
int val[ hash_size] ;
int cnt;
void pre ( )
{
cnt= 0 ;
memset ( head , - 1 , sizeof head) ;
memset ( to, 0 , sizeof to) ;
memset ( nxt, 0 , sizeof nxt) ;
}
int id;
void in ( int t, int value)
{
id= t% hash_size;
if ( ~ head[ id] )
{
nxt[ cnt] = head[ id] ;
}
head[ id] = cnt;
to[ cnt] = t;
val[ cnt] = value;
cnt++ ;
}
int i;
int query ( int t)
{
id= t% hash_size;
if ( ~ head[ id] )
{
for ( i= head[ id] ; ~ i; i= nxt[ i] )
{
if ( t== to[ i] )
{
return val[ i] ;
}
}
}
return - 1 ;
}
} ;
struct dor
{
int to;
int val;
dor * nxt;
} ;
class hx
{
public :
hx ( )
{
for ( int i= 0 ; i< 100 ; i++ )
{
ht[ i] = nullptr ;
}
}
~ hx ( )
{
dor * p, * q;
for ( int i= 0 ; i< 100 ; i++ )
{
p= q= ht[ i] ;
while ( p!= nullptr )
{
p= p- > nxt;
delete q;
q= p;
}
}
}
void in ( int t, int v)
{
int j= t% 100 ;
dor * p;
p= new dor;
p- > nxt= ht[ j] ;
ht[ j] = p;
p- > val= v;
p- > to= t;
}
int query ( int v)
{
int j= v% 100 ;
dor * p= ht[ j] ;
while ( p!= nullptr )
{
if ( p- > to== v)
{
return p- > val;
}
p= p- > nxt;
}
return - 1 ;
}
int del ( int v)
{
dor* bt;
int j= v% 100 ;
bt= ht[ j] ;
dor* q;
while ( bt!= nullptr )
{
if ( bt- > to== v)
{
if ( bt== ht[ j] )
{
ht[ j] = bt- > nxt;
delete bt;
return 1 ;
}
else
{
q- > nxt= bt- > nxt;
delete bt;
return 1 ;
}
}
q= bt;
bt= bt- > nxt;
}
return - 1 ;
}
private :
dor* ht[ 100 ] ;
} ;
int main ( )
{
pre ( ) ;
add ( 1 , 2 , 1 ) ;
add ( 1 , 3 , 1 ) ;
bianli ( 1 ) ;
haxi hs;
hs. pre ( ) ;
hs. in ( 1 , 2 ) ;
hs. in ( 2 , 3 ) ;
cout<< hs. query ( 0 ) << endl;
}