Link to this code: https://cses.fi/paste/049adcd6790c036f11c565/
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define speed                     \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);
#define ll long long
#define pb push_back
#define mem1(a) memset(a, -1, sizeof(a))
#define mem0(a) memset(a, 0, sizeof(a))
#define endl "\n"
#define mod 1000000007
#define mod1 998244353
#define ff first
#define ss second
#define MAX 500005
#define N 505
#define INF 1000000009
#define all(v) v.begin(), v.end()
#define sbit(a) __builtin_popcount(a)
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef pair<ll, ll> pll;
typedef pair<pll, ll> ppl;
typedef map<ll, ll> mpll;
typedef map<vector<ll>, ll> mpvl;
set<ll> adj[N];
ll cap[N][N];
ll power(ll x, ll y, ll p)
{
    ll res = 1;

    x = x % p;

    if (x == 0)
        return 0;
    while (y > 0)
    {

        if (y & 1)
            res = (res * x) % p;

        y = y >> 1;
        x = (x * x) % p;
    }

    return res;
}
ll n, m;
vector<pll> ans;
int bfs(int s, int t, vector<ll> &parent)
{
    fill(parent.begin(), parent.end(), -1);
    parent[s] = -2;
    queue<pair<ll, ll>> q;
    q.push({s, INF});

    while (!q.empty())
    {
        ll cur = q.front().first;
        ll flow = q.front().second;
        q.pop();
        for (auto next : adj[cur])
        {
            if (parent[next] == -1 && cap[cur][next])
            {
                parent[next] = cur;
                ll new_flow = min(flow, cap[cur][next]);
                if (next == t)
                    return new_flow;
                q.push({next, new_flow});
            }
        }
    }

    return 0;
}
ll maxflow(ll s, ll t)
{
    vector<ll> parent(n + 1);
    ll new_flow, flow = 0;
    while (new_flow = bfs(s, t, parent))
    {
        flow += new_flow;
        ll cur = t;
        bool f = 0;
        while (cur != s)
        {

            ll prev = parent[cur];
            if (f == 0)
            {
                ans.pb({prev, cur});
                f = 1;
            }
            cap[prev][cur] -= new_flow;
            cap[cur][prev] -= new_flow;
            cur = prev;
        }
    }
    return flow;
}
void solve()
{
    cin >> n >> m;
    for (ll i = 1; i <= m; i++)
    {
        ll x, y;
        cin >> x >> y ;
        adj[x].insert(y);
        adj[y].insert(x);
        cap[x][y] = 1;
        cap[y][x] = 1;
    }
    cout << maxflow(1, n) << endl;
    for (auto it : ans)
    {
        cout << it.ff << " " << it.ss << endl;
    }
}
int main()
{
    speed;
    ll kk;
    kk = 1;
    //cin >> kk;
    while (kk--)
    {
        solve();
    }
    return 0;
}