#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int>pi;
typedef pair<ll, ll>pl;
typedef vector<pi>vpi;
typedef vector<pl>vpl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<bool> vb;
const long double PI = acos(-1);
const ll oo = 1e18 + 7;
const int MOD = 1e9 + 7;
const int N = 2e5 + 7;
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define read(v) for (auto& it : v) scanf("%d", &it);
#define readl(v) for (auto& it : v) scanf("%lld", &it);
#define print(v) for (auto it : v) printf("%d ", it); puts("");
#define printl(v) for (auto it : v) printf("%lld ", it); puts("");
int n,m,p[N],sz[N],cnt=n,mx=1;
int find(int u){
if(u==p[u])
return u;
return p[u]=find(p[u]);
}
void unite(int u,int v){
u=find(u),v=find(v);
if(u==v)
return;
p[v]=u;
sz[u]+=sz[v];
cnt--;
mx=max(mx,sz[u]);
}
void solve() {
scanf("%d %d",&n,&m);
cnt=n;
for(int i=0;i<=n;i++)
p[i]=i,sz[i]=1;
for(int i=0;i<m;i++){
int u,v;
scanf("%d %d",&u,&v);
unite(u,v);
printf("%d %d\n",cnt,mx);
}
}
int t = 1;
int main() {
//scanf("%d", &t);
while (t--) solve();
}
I2RlZmluZSBfQ1JUX1NFQ1VSRV9OT19XQVJOSU5HUwojaW5jbHVkZSA8Yml0cy9zdGRjKysuaD4JCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CnR5cGVkZWYgbG9uZyBsb25nIGxsOwp0eXBlZGVmIGxvbmcgZG91YmxlIGxkOwp0eXBlZGVmIHZlY3RvcjxpbnQ+IHZpOwp0eXBlZGVmIHZlY3RvcjxsbD4gdmw7CnR5cGVkZWYgcGFpcjxpbnQsIGludD5waTsKdHlwZWRlZiBwYWlyPGxsLCBsbD5wbDsKdHlwZWRlZiB2ZWN0b3I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IlZCAlZCIsJm4sJm0pOwogICAgY250PW47CiAgICBmb3IoaW50IGk9MDtpPD1uO2krKykKICAgIHBbaV09aSxzeltpXT0xOwogICAgZm9yKGludCBpPTA7aTxtO2krKyl7CiAgICAgICAgaW50IHUsdjsKICAgICAgICBzY2FuZigiJWQgJWQiLCZ1LCZ2KTsKICAgICAgICB1bml0ZSh1LHYpOwogICAgICAgIHByaW50ZigiJWQgJWRcbiIsY250LG14KTsKICAgIH0KICAgIAp9CmludCB0ID0gMTsKaW50IG1haW4oKSB7CgkvL3NjYW5mKCIlZCIsICZ0KTsKCXdoaWxlICh0LS0pIHNvbHZlKCk7Cn0=