#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
class BearFair {
public :
vector < pair < int , int > > Arr;
string isFair( int , int , vector < int > , vector < int > ) ;
} ;
bool dp[ 51 ] [ 501 ] [ 501 ] ;
string BearFair:: isFair ( int n, int b, vector < int > upTo, vector < int > quantity)
{
int i,j,k,l;
Arr.push_back ( make_pair( 0 ,0 ) ) ;
for ( i= 0 ; i< ( int ) upTo.size ( ) ; ++ i)
Arr.push_back ( make_pair( upTo[ i] ,quantity[ i] ) ) ;
sort( Arr.begin ( ) ,Arr.end ( ) ) ;
dp[ 0 ] [ 0 ] [ 0 ] = 1 ;
int even , odd , pre = 0 ;
for ( i= 1 ; i< ( int ) Arr.size ( ) ; ++ i)
{
Arr[ i] .second - = pre;
pre+ = Arr[ i] .second ;
even = ( Arr[ i] .first - Arr[ i- 1 ] .first ) / 2 + ( ( Arr[ i] .first - Arr[ i- 1 ] .first ) % 2 && Arr[ i] .first % 2 == 0 ) ; // No of Most Even choices he can make at the i th segment
odd = Arr[ i] .first - Arr[ i- 1 ] .first - even; // Number of Most Odd choices he can make
even = min( even,Arr[ i] .second ) ;
odd = min( odd,Arr[ i] .second ) ;
for ( j= 0 ; j<= n/ 2 ; ++ j)
{
for ( k= 0 ; k<= n/ 2 ; ++ k)
{
dp[ i] [ j] [ k] = 0 ;
for ( l= 0 ; l<= min( even,j) ; ++ l)
if ( k- ( Arr[ i] .second - l) >= 0 )
dp[ i] [ j] [ k] | = ( Arr[ i] .second - l<= odd) * dp[ i- 1 ] [ j- l] [ k- ( Arr[ i] .second - l) ] ;
}
}
}
if ( dp[ Arr.size ( ) - 1 ] [ n/ 2 ] [ n/ 2 ] )
return "fair" ;
else
return "unfair" ;
}
I2luY2x1ZGUgPHZlY3Rvcj4KI2luY2x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