#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 100000000
#define INFLL 100000000000
#define MOD 1000000007
#define PI 3.14159265359
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};



int N, M;
bool seen[110000];
using Graph = vector<vector<int>>;

void dfs(int v, const Graph& G, vector<int>& order) {
  seen[v] = true;

  for (auto nv : G[v]) {
    if (seen[nv]) continue; 
    dfs(nv, G, order);
  }

  order.push_back(v);
}

int main () {
  cin >> N >> M;
  Graph G(N+1);
  Graph Gyaku(N+1);

  Rep(i, N-1+M) {
    int a, b;
    cin >> a >> b;
    G[a].push_back(b);
    Gyaku[b].push_back(a);
  }

  vector<int> order;
  rep(i, N) {
    if (seen[i]) continue;
    dfs(i, G, order);
  }

  reverse(All(order));

  map<int, int> mp;

  rep(i, N) {
    mp[order[i-1]] = i;
    //cout << order[i-1] << "\n";
  }

  rep(i, N) {
    if (mp[i] == 1) {
      cout << 0 << "\n";
    } else {
      int tmp = 0;
      int tmp_p = 0;
      for (auto nv: Gyaku[i]) {
        //cout << " " << nv << " " << mp[nv] << "\n";

        if (mp[nv] > tmp) {
          tmp = mp[nv];
          tmp_p = nv;
        }
      }

      cout << tmp_p << "\n";
    }
  }

}
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int __SIZE = 1 << 18;
char ibuf[__SIZE], *iS, *iT;

#define ge (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS++)) : *iS++)
#define ri read_int()
#define rl read_ll()
#define FILE(s) freopen(s"in", "r", stdin), freopen(s"out", "w", stdout)

template<typename T>
inline void read(T &x) {
	char ch, t = 0; x = 0;
	while(!isdigit(ch = ge)) t |= ch == '-';
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = ge;
	x = t ? -x : x;
}
inline int read_int() { int x; return read(x), x; }
inline ll read_ll() { ll x; return read(x), x; }

template<typename T>
inline void chkmin(T&a, T b) { a = a < b ? a : b; }

const int MAXN = 110;

int a[MAXN];
int js[MAXN];

int main() {
#ifdef LOCAL
	FILE("");
#endif
	int cnt = 0;
	int n = ri;
	int m = ri;
	if(m == 1) {
		if(n == 1) {
			cout << 1 << endl;
			cout << 1 << endl;
			cout << 1 << endl;
		} else {
			cout << n << endl;
			cout << 2 << endl;
			cout << 1 << ' ' << n - 1 << endl;
		}
	}
	else {
		for(int i = 1; i <= m; i++) {
			a[i] = ri;
			if(a[i] & 1)
				js[cnt++] = i;
		}
		if(cnt > 2) puts("Impossible");
		else {
			if(js[0] && js[0] != 1) swap(a[1], a[js[0]]);
			if(js[1] && js[1] != m) swap(a[m], a[js[1]]);
			for(int i = 1; i <= m; i++) printf("%d ", a[i]); puts("");
			a[1]++, a[m]--;
			if(!a[m]) --m;
			printf("%d\n", m);
			for(int i = 1; i <= m; i++) printf("%d ", a[i]); puts("");
		}
	}
	return 0;
}
