func_code_string: #include <bits/stdc++.h>   using namespace std;   template <class T1, class T2>   bool chmin(T1 &a, T2 b) {     return b < a && (a = b, true);   }   template <class T1, class T2>   bool chmax(T1 &a, T2 b) {     return a < b && (a = b, true);   }   struct MaxFlow {     struct edge {       int to, cap, rev;     };     vector<int> dist, it;     vector<vector<edge>> g;     MaxFlow(int n) : g(n), dist(n), it(n) {}     void add(int u, int v, int c) {       g[u].push_back({v, c, (int)g[v].size()});       g[v].push_back({u, 0, (int)g[u].size() - 1});     }     int calc(int s, int t) {       int res = 0;       while (bfs(s, t)) {         fill(it.begin(), it.end(), 0);         while (int f = dfs(s, t, 1e9)) res += f;       }       return res;     }     bool bfs(int s, int t) {       fill(dist.begin(), dist.end(), -1);       queue<int> q;       q.push(s);       dist[s] = 0;       while (!q.empty()) {         int v = q.front();         q.pop();         for (edge e : g[v])           if (e.cap > 0 && dist[e.to] < 0) {             dist[e.to] = dist[v] + 1;             q.push(e.to);           }       }       return dist[t] >= 0;     }     int dfs(int v, int t, int f) {       if (v == t) return f;       for (int &i = it[v]; i < g[v].size(); i++) {         edge &e = g[v][i];         if (e.cap > 0 && dist[v] < dist[e.to]) {           if (int d = dfs(e.to, t, min(f, e.cap))) {             e.cap -= d;             g[e.to][e.rev].cap += d;             return d;           }         }       }       return 0;     }   };   template <class T1, class T2>   void sortPair(vector<T1> &v1, vector<T2> &v2) {     vector<pair<T1, T2>> u(v1.size());     for (int i = 0; i < u.size(); i++) u[i] = make_pair(v1[i], v2[i]);     sort(u.begin(), u.end());     for (int i = 0; i < u.size(); i++) tie(v1[i], v2[i]) = u[i];   }   bool solve() {     int n, b, q;     cin >> n >> b >> q;     vector<int> u(q), v(q);     for (int i = 0; i < (q); i++) scanf( %d %d , &u[i], &v[i]);     u.push_back(b);     v.push_back(n);     q++;     sortPair(u, v);     for (int i = 0; i < (q - 1); i++)       if (v[i] > v[i + 1]) return false;     static int sum[10101][5];     for (int i = 0; i < (10101); i++) sum[i][i % 5]++;     for (int i = (1); i < (10101); i++)       for (int j = 0; j < (5); j++) sum[i][j] += sum[i - 1][j];     int lowSum = 0, highSum = 0;     MaxFlow mf(q + q * 5 + 5 + 2);     int src = q + q * 5 + 5;     int dst = src + 1;     int prevU = 0;     int prevV = 0;     for (int mod = 0; mod < (5); mod++) mf.add(q + q * 5 + mod, dst, n / 5);     for (int i = 0; i < (q); i++) {       int mustUse = v[i] - prevV;       int num = u[i] - prevU;       mf.add(src, i, mustUse);       for (int mod = 0; mod < (5); mod++) {         int mm = sum[u[i]][mod] - sum[prevU][mod];         mf.add(i, q + i * 5 + mod, mm);         mf.add(q + i * 5 + mod, q + q * 5 + mod, mm);       }       prevU = u[i];       prevV = v[i];     }     return mf.calc(src, dst) == n;   }   int main() {     cout << (solve() ?  fair  :  unfair ) << endl;     return 0;   }   