1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define endl "\n"
#define mp make_pair
#define st first
#define nd second
#define pii pair<int, int>
#define pb push_back
#define _upgrade ios_base::sync_with_stdio(0), cout.setf(ios::fixed), cout.precision(10), cin.tie(0), cout.tie(0);
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define fwd(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(c) (c).begin(), (c).end()
#define sz(X) (int)((X).size())
typedef long double ld;
typedef unsigned long long ull;
typedef long long ll;
// mt19937_64 gen(2137);uniform_int_distribution<int> distr(0, 1e9);auto my_rand = bind(distr, gen); // my_rand() zwraca teraz liczbe z przedzialu [a, b]
#ifdef LOCAL
ostream &operator<<(ostream &out, string str) {
   for (char c : str)
      out << c;
   return out;
}
template <class L, class R> ostream &operator<<(ostream &out, pair<L, R> p) { return out << "(" << p.st << ", " << p.nd << ")"; }
template <class L, class R, class S> ostream &operator<<(ostream &out, tuple<L, R, S> p) {
   auto &[a, b, c] = p;
   return out << "(" << a << ", " << b << ", " << c << ")";
}
template <class T> auto operator<<(ostream &out, T a) -> decltype(a.begin(), out) {
   out << '{';
   for (auto it = a.begin(); it != a.end(); it = next(it))
      out << (it != a.begin() ? ", " : "") << *it;
   return out << '}';
}
void dump() { cerr << "\n"; }
template <class T, class... Ts> void dump(T a, Ts... x) {
   cerr << a << ", ";
   dump(x...);
}
#define debug(...) cerr << "[" #__VA_ARGS__ "]: ", dump(__VA_ARGS__)
#else
#define debug(...) 42
#endif

// ======== DINIC by Marek Cygan ========
namespace DINIC {
   typedef int res_type;
   const int EPS = 0;
   const int INF = 1e9;
   const int MAXN = 1e6; // ustaw odpowiednia wartosc!

   struct edge {
      int v, rev;
      res_type res;
   };

   vector<edge> nbrs[MAXN]; // puste przed dodawaniem krawedzi!
   int start[MAXN], dist[MAXN];

   void addEdge(int a, int b, res_type c) {
      debug(a, b, c);
      nbrs[a].pb({b, sz(nbrs[b]), c});
      nbrs[b].pb({a, sz(nbrs[a]) - 1, 0});
   }
   bool bfs(int s, int t, int n) {
      rep(i, n) dist[i] = -1;
      dist[s] = 0;
      queue<int> q;
      q.push(s);
      while (!q.empty()) {
         int u = q.front();
         q.pop();
         for (edge &e : nbrs[u])
            if (e.res > EPS && dist[e.v] == -1) {
               dist[e.v] = dist[u] + 1;
               q.push(e.v);
            }
      }
      return dist[t] != -1;
   }

   res_type dfs(int x, int t, res_type mini) {
      res_type ans = 0;
      if (x == t)
         return mini;
      if (mini <= EPS)
         return 0;
      for (int &i = start[x]; i < sz(nbrs[x]); ++i) {
         edge &e = nbrs[x][i];
         if (dist[x] + 1 == dist[e.v] && e.res > EPS) {
            res_type added = dfs(e.v, t, min(mini, e.res));
            e.res -= added;
            nbrs[e.v][e.rev].res += added;
            mini -= added;
            ans += added;
            if (mini <= EPS)
               break;
         }
      }
      return ans;
   }

   int ans = 0;
   void maxFlow(int s, int t, int n) {
      int N = 2 * n + 2;
      while (bfs(s, t, N)) {
         rep(i, N) start[i] = 0;
         ans += dfs(s, t, INF);
         // debug(ans);
      }
   }

   void run(int n, int x) {
      int s = 2 * n;
      int t = 2 * n + 1;
      maxFlow(s, t, n);
   }

   void addEdge(int n, int x) {
      int t = 2 * n + 1;
      addEdge(n + x, t, 1);
   }

   bool should_run(int n, int x) { return dist[n + x] != -1; }

   void init(vector<vector<int>> &G, int n, int k) {
      debug(G);
      ans = 0;
      int s = 2 * n;
      int t = 2 * n + 1;

      rep(i, t + 10) nbrs[i].clear();
      rep(i, n) {
         addEdge(i, n + i, 1);
         for (auto a : G[i])
            addEdge(n + i, a, 1);
      }
      rep(i, k) addEdge(s, i, 1);
      maxFlow(s, t, n);
      debug(ans);
   }

} // namespace DINIC

int32_t main() {
   _upgrade;
   int n, m, k;
   cin >> n >> m >> k;

   vector<vector<int>> G(n);
   rep(i, m) {
      int a, b;
      cin >> a >> b;
      debug(a, b);
      G[--a].push_back(--b);
   }
   rep(i, n) random_shuffle(all(G[i]));

   vector<int> res(k + 1);
   for (int l = k; l < n; l++) {
      debug(DINIC::ans);
      DINIC::init(G, n, k);
      for (int s = l; s < n; s++) {
         DINIC::addEdge(n, s);
         if (DINIC::should_run(n, s))
            DINIC::run(n, s);
         debug(DINIC::ans);
         res[DINIC::ans]++;
      }
   }
   rep(i, k + 1) cout << res[i] << endl;
}