Problem: Berland has n cities, some of them are connected by bidirectional roads. For each road we know whether it is asphalted or not.

The King of Berland Valera II wants to asphalt all roads of Berland, for that he gathered a group of workers. Every day Valera chooses exactly one city and orders the crew to asphalt all roads that come from the city. The valiant crew fulfilled the King's order in a day, then workers went home.

Unfortunately, not everything is as great as Valera II would like. The main part of the group were gastarbeiters — illegal immigrants who are enthusiastic but not exactly good at understanding orders in Berlandian. Therefore, having received orders to asphalt the roads coming from some of the city, the group asphalted all non-asphalted roads coming from the city, and vice versa, took the asphalt from the roads that had it.

Upon learning of this progress, Valera II was very upset, but since it was too late to change anything, he asked you to make a program that determines whether you can in some way asphalt Berlandian roads in at most n days. Help the king.

Input

The first line contains two space-separated integers n, m <image> — the number of cities and roads in Berland, correspondingly. Next m lines contain the descriptions of roads in Berland: the i-th line contains three space-separated integers ai, bi, ci (1 ≤ ai, bi ≤ n; ai ≠ bi; 0 ≤ ci ≤ 1). The first two integers (ai, bi) are indexes of the cities that are connected by the i-th road, the third integer (ci) equals 1, if the road was initially asphalted, and 0 otherwise. 

Consider the cities in Berland indexed from 1 to n, and the roads indexed from 1 to m. It is guaranteed that between two Berlandian cities there is not more than one road.

Output

In the first line print a single integer x (0 ≤ x ≤ n) — the number of days needed to asphalt all roads. In the second line print x space-separated integers — the indexes of the cities to send the workers to. Print the cities in the order, in which Valera send the workers to asphalt roads. If there are multiple solutions, print any of them. 

If there's no way to asphalt all roads, print "Impossible" (without the quotes).

Examples

Input

4 4
1 2 1
2 4 0
4 3 1
3 2 0


Output

4
3 2 1 3


Input

3 3
1 2 0
2 3 0
3 1 0


Output

Impossible

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
long long fac[1000006];
inline long long exp(long long x, long long n) {
  long long r = 1;
  x = x;
  while (n) {
    if (n % 2) r = (r * x) % 10;
    x = (x * x) % 10;
    n = n / 2;
  }
  return r;
}
inline long long mmi(long long a) { return exp(a, 10 - 2) % 10; }
inline long long fact(long long n) {
  long long res = 1;
  for (long long i = 1; i < (n + 1); ++i) {
    res = (res * i) % 10;
  }
  return res;
}
inline void fact_a() {
  fac[0] = 1;
  fac[1] = 1;
  for (long long i = 1; i < (105); ++i) {
    fac[i] = (fac[i - 1] * i) % 10;
  }
}
inline long long inv_fact(long long n) {
  long long par = fac[n];
  long long res = mmi(par);
  return res;
}
inline long long comb(long long n, long long r) {
  if (n == r && r == 0) return 1;
  if (n < r) return 0;
  return ((fac[n] * inv_fact(r)) % 10 * inv_fact(n - r)) % 10;
}
struct triplet {
  long long a, b, c;
};
bool operator<(const triplet &t1, const triplet &t2) {
  if (t1.a < t2.a) return true;
  if (t1.a == t2.a && t1.b < t2.b) return true;
  if (t1.a == t2.a && t1.b == t2.b && t1.c < t2.c) return true;
  return false;
}
pair<long long, pair<long long, long long> > ex_gcd(long long a, long long b) {
  if (b == 0) {
    return make_pair(a, make_pair(1, 0));
  }
  pair<long long, pair<long long, long long> > p = ex_gcd(b, a % b);
  long long gcd = p.first;
  long long x1 = p.second.first;
  long long y1 = p.second.second;
  long long x = y1;
  long long y = x1 - (a / b) * y1;
  return make_pair(gcd, make_pair(x, y));
}
long long prime[3000006];
long long spf_prime[3000006];
void sieve() {
  prime[1] = 1;
  for (long long i = 2; i * i <= 3000000; i++)
    if (prime[i] == 0)
      for (long long j = i * i; j <= 3000000; j += i) prime[j] = 1;
}
void spf() {
  for (long long i = 2; i * i <= 3000000; i++)
    if (!spf_prime[i])
      for (long long j = i * i; j <= 3000000; j += i)
        if (!spf_prime[j]) spf_prime[j] = i;
  for (long long i = 2; i <= 3000000; i++)
    if (!spf_prime[i]) spf_prime[i] = i;
}
long long getparent_BIT(long long idx) { return idx - (idx & -idx); }
long long getnext_BIT(long long idx) { return idx + (idx & -idx); }
long long getsum_BIT(long long idx, long long BIT[], long long n) {
  long long sum = 0;
  while (idx > 0) {
    sum += BIT[idx];
    idx = getparent_BIT(idx);
  }
  return sum;
}
void update_BIT(long long idx, long long BIT[], long long val, long long n) {
  while (idx <= n) {
    BIT[idx] += val;
    idx = getnext_BIT(idx);
  }
}
void build_BIT(long long BIT[], long long a[], long long n) {
  for (long long i = 0; i < (n); ++i) {
    update_BIT(i, BIT, a[i], n);
  }
}
void comp_lps(string s, long long lps[], long long n) {
  long long i = 1, j = 0;
  while (i < n) {
    if (s[i] == s[j]) {
      lps[i++] = ++j;
    } else {
      if (j != 0)
        j = lps[j - 1];
      else
        lps[i++] = 0;
    }
  }
}
void dfs_l(long long u, vector<vector<long long> > &adj, long long status[]) {
  if (status[u] == 1) return;
  status[u] = 1;
  for (long long i = 0; i < (adj[u].size()); ++i) dfs_l(adj[u][i], adj, status);
}
long long dij(long long u, long long n,
              vector<vector<pair<long long, long long> > > &adj,
              long long status[]) {
  long long dist[n];
  for (long long i = 0; i < (n); ++i) dist[i] = 1000000000;
  dist[0] = 0;
  priority_queue<pair<long long, long long>,
                 vector<pair<long long, long long> >,
                 greater<pair<long long, long long> > >
      q;
  q.push(make_pair(0, 0));
  while (!q.empty()) {
    pair<long long, long long> p;
    p = q.top();
    q.pop();
    long long x = p.second;
    long long w = p.first;
    if (status[x] == 1) continue;
    status[x] = 1;
    for (long long i = 0; i < (adj[x].size()); ++i) {
      long long ww = adj[x][i].first;
      long long y = adj[x][i].second;
      if (dist[x] + ww < dist[y]) {
        dist[y] = dist[x] + ww;
        q.push(make_pair(dist[y], y));
      }
    }
  }
  if (dist[n - 1] >= 1000000000) return -1;
  return dist[n - 1];
}
long long phi(long long n) {
  vector<long long> v;
  long long k = n;
  ;
  for (long long i = 2; i * i <= n; i++) {
    if (k % i == 0) {
      v.push_back(i);
      while (k % i == 0) k /= i;
    }
  }
  if (k > 1) v.push_back(k);
  long long ans = n;
  for (long long i = 0; i < (v.size()); ++i) ans -= (ans / v[i]);
  return ans;
}
struct trie {
  struct trie *left, *right;
  bool isend;
};
trie *get_trie() {
  trie *ptr = new trie;
  ptr->left = NULL;
  ptr->right = NULL;
  ptr->isend = false;
  return ptr;
}
bool isempty(trie *root) {
  if (root->left == NULL && root->right == NULL) return true;
  return false;
}
void insert_trie(trie *root, string key) {
  trie *ptr = root;
  for (long long i = 0; i < (key.size()); ++i) {
    if (key[i] == '0') {
      if (ptr->left == NULL) {
        ptr->left = get_trie();
      }
      ptr = ptr->left;
    } else {
      if (ptr->right == NULL) ptr->right = get_trie();
      ptr = ptr->right;
    }
  }
  ptr->isend = true;
}
trie *remove_trie(trie *root, string key, long long idx = 0) {
  if (root == NULL) return NULL;
  if (idx == key.size()) {
    if (isempty(root)) {
      delete (root);
      root = NULL;
    }
    return root;
  }
  if (key[idx] == '0')
    root->left = remove_trie(root->left, key, idx + 1);
  else
    root->right = remove_trie(root->right, key, idx + 1);
  if (isempty(root)) {
    delete (root);
    root = NULL;
  }
  return root;
}
long long search_trie(trie *root, string key) {
  trie *ptr = root;
  string s = "";
  for (long long i = 0; i < (key.size()); ++i) {
    if (key[i] == '0') {
      if (ptr->right != NULL) {
        ptr = ptr->right;
        s += '1';
      } else {
        ptr = ptr->left;
        s += '0';
      }
    } else {
      if (ptr->left != NULL) {
        ptr = ptr->left;
        s += '1';
      } else {
        ptr = ptr->right;
        s += '0';
      }
    }
  }
  long long res = 0;
  reverse(s.begin(), s.end());
  for (long long i = s.length() - 1; i >= (0); --i)
    res = res * 2 + (s[i] - '0');
  return res;
}
struct Comp {
  bool operator()(const std::pair<int, int> &a, const std::pair<int, int> &b) {
    if (a.first != b.first) {
      return a.first < b.first;
    }
    return a.second > b.second;
  }
};
void dearr() {
  long long dar[1005];
  dar[0] = 1;
  dar[1] = 0;
  dar[2] = 1;
  for (long long i = 3; i < (1002); ++i) {
    dar[i] = (i - 1) * (dar[i - 1] + dar[i - 2]);
  }
}
long long siz[200];
long long parent[200];
void make_set(long long v) {
  parent[v] = v;
  siz[v] = 1;
}
long long find_set(long long v) {
  if (v == parent[v]) return v;
  return find_set(parent[v]);
}
void union_set(long long a, long long b) {
  a = find_set(a);
  b = find_set(b);
  if (a != b) {
    if (siz[a] < siz[b]) swap(a, b);
    parent[b] = a;
    siz[a] += siz[b];
  }
}
map<pair<long long, long long>, long long> gap;
void rec(long long clr, long long u, vector<vector<long long> > &adj,
         long long status[], map<long long, long long> &mp,
         map<long long, long long> &h, long long &cc) {
  if (h.find(mp[u]) == h.end())
    h[mp[u]] = clr;
  else {
    if (h[mp[u]] != clr) {
      cc = 1;
      return;
    }
  }
  if (status[u] == 1) return;
  status[u] = 1;
  for (long long i = 0; i < (adj[u].size()); ++i) {
    if (gap.find(make_pair(adj[u][i], u)) == gap.end())
      rec((clr + 1) % 2, adj[u][i], adj, status, mp, h, cc);
    else
      rec(clr, adj[u][i], adj, status, mp, h, cc);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n, m;
  cin >> n >> m;
  map<long long, long long> mp;
  memset(siz, 0, sizeof(siz));
  vector<vector<long long> > adj(n + 1);
  for (long long i = 0; i < (m); ++i) {
    long long x, y, z;
    cin >> x >> y >> z;
    x--;
    y--;
    if (siz[x] == 0) make_set(x);
    if (siz[y] == 0) make_set(y);
    if (z == 1) {
      union_set(x, y);
      gap[make_pair(x, y)] = 1;
      gap[make_pair(y, x)] = 1;
    }
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  for (long long i = 0; i < (n); ++i) {
    mp[i] = find_set(i);
  }
  map<long long, long long> h;
  long long status[n];
  memset(status, 0, sizeof(status));
  long long cc = 0;
  long long dd = 0;
  for (long long i = 0; i < (n); ++i) {
    if (status[i] == 0) {
      cc = 0;
      rec(0, i, adj, status, mp, h, cc);
      if (cc == 1) break;
    }
  }
  if (cc == 1)
    cout << "Impossible"
         << "\n";
  else {
    vector<long long> rr;
    for (long long i = 0; i < (n); ++i) {
      if (h[mp[i]] == 1) rr.push_back(i + 1);
    }
    cout << rr.size() << "\n";
    for (long long i = 0; i < (rr.size()); ++i) cout << rr[i] << " ";
    cout << "\n";
  }
}