def li():
  return list(map(int, input().split(" ")))
for _ in range(int(input())):
  a, b=li()
  a/=4#p/4 <= q
  if b != 0:
    ans = 1/2 + (a*a)/(b*4*a)
    ans -= max(0, (b-4*a)*(a/4-b))/4
    if ans<0:
        ans = 1/2 + (a*a)/(b*4*a)
    print("{:.8f}".format(ans))
  else:
    print(1)


def li():
  return list(map(int, input().split(" ")))
for _ in range(int(input())):
  a, b=li()
  if b != 0 and b != 0:
    s = (max(0, a-4*b) + a)/2
    s*=min((a/4), b)
    ans = 1/2 + s/(2*a*b)
    print("{:.8f}".format(ans))
  elif b == 0:
    print(1)
  else:
    print(0.5)


def li():
  return list(map(int, input().split(" ")))
for _ in range(int(input())):
  a, b=li()
  if b != 0:
    if(a > 4*b):
      ans = 1/2 + (a+max(0, (a-4*b)))/(b*4*a)
    else:
      a/=4
      ans = 1/2 + (a*a)/(b*4*a)
    print("{:.8f}".format(ans))
  else:
    print(1)


def li():
  return list(map(int, input().split(" ")))
for _ in range(int(input())):
  a, b=li()
  a/=4
  ans = 1/2 + (a*a/(2))*(b / (8*a))
  print("{:.8f}".format(ans))


def li():
  return list(map(int, input().split(" ")))
for _ in range(int(input())):
  a, b=li()
  a/=4#p/4 <= q
  if b != 0:
    ans = 1/2 + (a*a)/(b*4*a)
    ans -= max(0, (b-4*a)*(a/4-b))
    if ans<0:
        ans = 1/2 + (a*a)/(b*4*a)
    print("{:.8f}".format(ans))
  else:
    print(1)


def li():
  return list(map(int, input().split(" ")))
for _ in range(int(input())):
  a, b=li()
  a/=4#p/4 <= q
  if b != 0:
    ans = 1/2 + (a*a)/(b*4*a) + (max(0, (b-4*a)*(a/4-b))/2)/(a*b)
    ans -=
    if ans<0:
        ans = 1/2 + (a*a)/(b*4*a)
    print("{:.8f}".format(ans))
  else:
    print(1)


def li():
  return list(map(int, input().split(" ")))
for _ in range(int(input())):
  a, b=li()
  a/=4#p/4 <= q
  if b != 0:
    ans = 1/2 + (a*a)/(b*4*a) - (max(0, (b-4*a)*(a/4-b))/2)/(a*b)
    if ans<0:
        ans = 1/2 + (a*a)/(b*4*a)
    print("{:.8f}".format(ans))
  else:
    print(1)


def li():
  return list(map(int, input().split(" ")))
for _ in range(int(input())):
  a, b=li()
  if b != 0 and b != 0:
    s = (max(0, a-4*b) + a)/2
    s*=min((a/4), b)
    ans = 1/2 + s/(2*a*b)
    print("{:.8f}".format(ans), (max(0, a-4*b) + a)/2)
  else if b == 0:
    print(1)
  else:
    print(0.5)


def li():
  return list(map(int, input().split(" ")))
for _ in range(int(input())):
  a, b=li()
  if b != 0:
    s = (max(0, a-4*b) + a)/2
    s*=min((a/4), b)
    ans = 1/2 + s/(2*a*b)
    print("{:.8f}".format(ans), (max(0, a-4*b) + a)/2)
  else:
    print(1)


def li():
  return list(map(int, input().split(" ")))
for _ in range(int(input())):
  a, b=li()
  if b != 0:
    s = (max(0, a-4*b) + a)/2
    s*=min((a/4), b)
    ans = 1/2 + s/(2*a*b)
    print("{:.8f}".format(ans))
  else:
    print(1)


def li():
  return list(map(int, input().split(" ")))
for _ in range(int(input())):
  a, b=li()
  a/=4#p/4 <= q
  ans = 1/2 + (a*a)/(b*4*a)
  print("{:.8f}".format(ans))


def li():
  return list(map(int, input().split(" ")))
for _ in range(int(input())):
  a, b=li()
  if b != 0 and b != 0:
    s = (max(0, a-4*b) + a)/2
    s*=min((a/4), b)
    ans = 1/2 + s/(2*a*b)
    print("{:.8f}".format(ans), (max(0, a-4*b) + a)/2)
  elif b == 0:
    print(1)
  else:
    print(0.5)


#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
using namespace std;
#define pb push_back
const int N = 2e3 + 5;
vector<int> g[N];
vector<int> vis, ans[2];
int n, m;
void makeG() {
    for(int i = 0; i < n; i++)
        g[i].clear();
    for(int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        g[u].pb(v);
        g[v].pb(u);
    }
    vis.assign(n, 0);
}

bool dfs(int v, int c) {
    vis[v] = c;
    ans[c==1?1:0].pb(v+1);
    bool ok = 1;
    for (auto x: g[v]) {
        if (vis[x])
            ok &= (!(vis[x]+c));
        else
            ok &= dfs(x, -c);
    }
    return ok;
}

int32_t main() {
    IOS;
    int i;
    cin >> n >> m;
    makeG();
    bool ok = 1;
    for(i = 0; i < n; i++) {
        if (!vis[i] and dfs(i, 1)) break;
        ans[0].clear(); ans[1].clear();
    }
    if (!ans[0].size() and !ans[1].size())
        cout << -1 << endl;
    else {
        for (auto& x: ans) {
            cout << x.size() << endl;
            for (auto& y: x)
                cout << y << " ";
            cout << endl;
        }
    }
    return 0;
}


#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
using namespace std;
#define pb push_back
const int N = 1e5 + 5;
vector<int> g[N];
vector<int> vis, ans[2];
int n, m;
void makeG() {
    for(int i = 0; i < n; i++)
        g[i].clear();
    for(int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        g[u].pb(v);
        g[v].pb(u);
    }
    vis.assign(n, 0);
}

bool dfs(int v, int c) {
    vis[v] = c;
    ans[c==1?1:0].pb(v+1);
    bool ok = 1;
    for (auto x: g[v]) {
        if (vis[x])
            ok &= (!(vis[x]+c));
        else
            ok &= dfs(x, -c);
    }
    return ok;
}

int32_t main() {
    IOS;
    int i;
    cin >> n >> m;
    makeG();
    bool ok = 1;
    for(i = 0; i < n; i++) {
        if (!vis[i] and dfs(i, 1)) break;
        ans[0].clear(); ans[1].clear();
    }
    if (!ans[0].size() and !ans[1].size())
        cout << -1 << endl;
    else {
        for (auto& x: ans) {
            cout << x.size() << endl;
            for (auto& y: x)
                cout << y << " ";
            cout << endl;
        }
    }
    return 0;
}


#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
using namespace std;
#define pb push_back
#define sz(x) (int)(x).size()
const int N = 2e5 + 10;

struct DSU {
    int n, parent[N], node[N], root[N];
    DSU (int Q) : n(Q) {
        for(int i = 0; i < n; i++) {
            parent[i] = i;
            node[i] = 1;
            root[i] = -1;
        }
    }
    int findparent (int x) {
        if (parent[x] == x)
            return x;
        return parent[x] = findparent(parent[x]);
    }
    void merge (int x, int y) {
        x = findparent(x);
        y = findparent(y);
        if (x == y) return;
        if (node[x] > node[y])
            parent[y] = x, node[x] += node[y];
        else
            parent[x] = y, node[y] += node[x];
    }
    bool same (int x, int y) {
        return findparent(x) == findparent(y);
    }
    bool only (int x) {
        return node[findparent(x)] == 1;
    }
};

int32_t main() {
    IOS;
    int i, n, m;
    vector<int> ans[2];
    cin >> n >> m;
    DSU g(2*n+1);
    for(i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        u--; v--;
        g.merge(u, v+n);
        g.merge(u+n, v);
    }
    for(i = 0; i < n; i++)
        if (g.same(i, i+n)) return cout << -1, 0;
    for(i = 0; i < n; i++) {
        int x = g.findparent(i);
        if (g.root[x] == -1) {
            int y = g.findparent(i+n);
            g.root[x] = 0;
            g.root[y] = 1;
        }
        ans[g.root[x]].pb(i+1);
    }
    for (auto& x: ans) {
        cout << sz(x) << endl;
        for (auto& y: x)
            cout << y << " ";
        cout << endl;
    }
    return 0;
}


#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
using namespace std;
#define pb push_back
#define sz(x) (int)(x).size()
const int N = 2e5 + 10;

struct DSU {
    int n, parent[N], node[N], root[N];
    DSU (int Q) : n(Q) {
        for(int i = 0; i < n; i++) {
            parent[i] = i;
            node[i] = 1;
            root[i] = root[2*i] = -1;
        }
    }
    int findparent (int x) {
        if (parent[x] == x)
            return x;
        return parent[x] = findparent(parent[x]);
    }
    void merge (int x, int y) {
        x = findparent(x);
        y = findparent(y);
        if (x == y) return;
        if (node[x] > node[y])
            parent[y] = x, node[x] += node[y];
        else
            parent[x] = y, node[y] += node[x];
    }
    bool same (int x, int y) {
        return findparent(x) == findparent(y);
    }
    bool only (int x) {
        return node[findparent(x)] == 1;
    }
};

int32_t main() {
    IOS;
    int i, n, m;
    vector<int> ans[2];
    cin >> n >> m;
    DSU g(2*n+1);
    for(i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        u--; v--;
        g.merge(u, v+n);
        g.merge(u+n, v);
    }
    for(i = 0; i < n; i++)
        if (g.same(i, i+n)) return cout << -1, 0;
    for(i = 0; i < n; i++) {
        int x = g.findparent(i);
        if (g.root[x] == -1) {
            int y = g.findparent(i+n);
            g.root[x] = 0;
            g.root[y] = 1;
        }
        ans[g.root[x]].pb(i+1);
    }
    for (auto& x: ans) {
        cout << sz(x) << endl;
        for (auto& y: x)
            cout << y << " ";
        cout << endl;
    }
    return 0;
}


#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
using namespace std;
#define pb push_back
const int N = 1e5 + 5;
vector<int> g[N];
vector<int> vis, ans[2];
int n, m;
void makeG() {
    for(int i = 0; i < n; i++)
        g[i].clear();
    for(int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        g[u].pb(v);
        g[v].pb(u);
    }
    vis.assign(n, 0);
}

bool dfs(int v, int c) {
    vis[v] = c+1;
    ans[c].pb(v+1);
    bool ok = 1;
    for (auto x: g[v]) {
        if (vis[x])
            ok &= ((vis[x]-1)^c);
        else
            ok &= dfs(x, c^1);
    }
    return ok;
}

int32_t main() {
    IOS;
    int i;
    cin >> n >> m;
    makeG();
    bool ok = 1;
    for(i = 0; i < n; i++) {
        if (!vis[i] and dfs(i, 0)) break;
        ans[0].clear(); ans[1].clear();
    }
    if (!ans[0].size() and !ans[1].size())
        cout << -1 << endl;
    else {
        for (auto& x: ans) {
            cout << x.size() << endl;
            for (auto& y: x)
                cout << y << " ";
            cout << endl;
        }
    }
    return 0;
}


#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
using namespace std;
#define pb push_back
const int N = 1e5 + 5;
vector<int> g[N];
vector<int> vis, ans[2];
int n, m;
void makeG() {
    for(int i = 0; i < n; i++)
        g[i].clear();
    for(int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        g[u].pb(v);
        g[v].pb(u);
    }
    vis.assign(n, 0);
}

bool dfs(int v, int c) {
    vis[v] = c+1;
    ans[c].pb(v+1);
    bool ok = 1;
    for (auto x: g[v]) {
        if (vis[x])
            ok &= ((vis[x]-1)^c);
        else
            ok &= dfs(x, c^1);
    }
    return ok;
}

int32_t main() {
    IOS;
    int i;
    cin >> n >> m;
    makeG();
    bool ok = 1;
    for(i = 0; i < n; i++)
        if (!vis[i] and !dfs(i, 0)) return cout << -1, 0;
    for (auto& x: ans) {
        cout << x.size() << endl;
        for (auto& y: x)
            cout << y << " ";
        cout << endl;
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
int n,m;
int color[100005];
int component[100005];
vector<int> G[100005];
vector<int> Pari , Arya;
vector<bool> visited(100005 , false);
bool not_bipartite = false;
map<int,int> count_comp;

void dfs(int u , int c , int comp) {
    visited[u] = true;
    color[u] = c;
    component[u] = comp;
    count_comp[comp]++;
    if(c == 1)
        c = 2;
    else
        c = 1;
    for(auto v : G[u]){
        if(!visited[v])
            dfs(v , c , comp);
        else{
            if(color[v] != c)
                not_bipartite = true;
        }
    }

}

int main(){
    cin >> n >> m;
    for(int i = 1 ; i )
    for(int i = 0 ; i < m ; ++i){
        int u , v;
        cin >> u >> v;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    int cnt = 1;
    for(int i = 1 ; i <= n ; ++i){
        if(!visited[i]){
            dfs(i , 1 , cnt);
            cnt++;
        }
    }
    if(not_bipartite){
        printf("-1");
        return 0;
    }
    for(int i = 1 ; i <= n ; ++i){
        if(color[i] == 1)
            Pari.push_back(i);
        if(color[i] == 2)
            Arya.push_back(i);
    }
    printf("%d\n",Pari.size());
    sort(Pari.begin(),Pari.end());
    sort(Arya.begin(),Arya.end());
    for(auto c : Pari)
        printf("%d ",c);
    printf("\n%d\n",Arya.size());
    for(auto c : Arya)
        printf("%d ",c);

}


#include <bits/stdc++.h>

using namespace std;
int n,m;
int color[100005];
int component[100005];
vector<int> G[100005];
vector<int> Pari , Arya;
vector<bool> visited(100005 , false);
bool not_bipartite = false;
map<int,int> count_comp;

void dfs(int u , int c , int comp) {
    visited[u] = true;
    color[u] = c;
    component[u] = comp;
    count_comp[comp]++;
    if(c == 1)
        c = 2;
    else
        c = 1;
    for(auto v : G[u]){
        if(!visited[v])
            dfs(v , c , comp);
        else{
            if(color[v] != c)
                not_bipartite = true;
        }
    }

}

int main(){
    cin >> n >> m;
    for(int i = 0 ; i < m ; ++i){
        int u , v;
        cin >> u >> v;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    int cnt = 1;
    for(int i = 1 ; i <= n ; ++i){
        if(!visited[i]){
            dfs(i , 1 , cnt);
            cnt++;
        }
    }
    if(not_bipartite){
        printf("-1");
        return 0;
    }
    for(auto c : count_comp){
        if(c.second == 1)
            continue;
        int n_comp = c.first;
        for(int i = 1 ; i <= n ; ++i){
            if(component[i] == n_comp and color[i] == 1)
                Pari.push_back(i);
            if(component[i] == n_comp and color[i] == 2)
                Arya.push_back(i);
        }
    }
    printf("%d\n",Pari.size());
    sort(Pari.begin(),Pari.end());
    sort(Arya.begin(),Arya.end());
    for(auto c : Pari)
        printf("%d ",c);
    printf("\n%d\n",Arya.size());
    for(auto c : Arya)
        printf("%d ",c);

}


#include <bits/stdc++.h>

using namespace std;
int n,m;
int color[100005];
int component[100005];
vector<int> G[100005];
vector<bool> visited(100005 , false);
bool not_bipartite = false;
map<int,int> count_comp;

void dfs(int u , int c , int comp) {
    visited[u] = true;
    color[u] = c;
    component[u] = comp;
    count_comp[comp]++;
    if(c == 1)
        c = 2;
    else
        c = 1;
    for(auto v : G[u]){
        if(!visited[v])
            dfs(v , c , comp);
        else{
            if(color[v] != c)
                not_bipartite = true;
        }
    }

}

int main(){
    cin >> n >> m;
    for(int i = 0 ; i < m ; ++i){
        int u , v;
        cin >> u >> v;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    int cnt = 1;
    for(int i = 1 ; i <= n ; ++i){
        if(!visited[i]){
            dfs(i , 1 , cnt);
            cnt++;
        }
    }
    if(not_bipartite){
        printf("-1");
        return 0;
    }
    for(auto c : count_comp){
        if(c.second == 1)
            continue;
        int n_comp = c.first;
        int cnt1 = 0 , cnt2 = 0;
        for(int i = 1 ; i <= n ; ++i){
            if(component[i] == n_comp and color[i] == 1)
                cnt1++;
            if(component[i] == n_comp and color[i] == 2)
                cnt2++;
        }
        if(cnt1 != 0 and cnt2 != 0){
            printf("%d\n",cnt1);
            for(int i = 1 ; i <= n ; ++i){
                if(component[i] == n_comp and color[i] == 1)
                    printf("%d ",i);
            }
            printf("\n");
            printf("%d\n",cnt2);
            for(int i = 1 ; i <= n ; ++i){
                if(component[i] == n_comp and color[i] == 2)
                    printf("%d ",i);
            }
            return 0 ;
        }
    }

}


#include <bits/stdc++.h>

using namespace std;
int n,m;
int color[100005];
int component[100005];
vector<int> G[100005];
vector<int> Pari , Arya;
vector<bool> visited(100005 , false);
bool not_bipartite = false;
map<int,int> count_comp;

void dfs(int u , int c , int comp) {
    visited[u] = true;
    color[u] = c;
    component[u] = comp;
    count_comp[comp]++;
    if(c == 1)
        c = 2;
    else
        c = 1;
    for(auto v : G[u]){
        if(!visited[v])
            dfs(v , c , comp);
        else{
            if(color[v] != c)
                not_bipartite = true;
        }
    }

}

int main(){
    cin >> n >> m;
    for(int i = 0 ; i < m ; ++i){
        int u , v;
        cin >> u >> v;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    int cnt = 1;
    for(int i = 1 ; i <= n ; ++i){
        if(!visited[i]){
            dfs(i , 1 , cnt);
            cnt++;
        }
    }
    if(not_bipartite){
        printf("-1");
        return 0;
    }
    for(int i = 1 ; i <= n ; ++i){
        if(color[i] == 1)
            Pari.push_back(i);
        if(color[i] == 2)
            Arya.push_back(i);
    }
    printf("%d\n",Pari.size());
    sort(Pari.begin(),Pari.end());
    sort(Arya.begin(),Arya.end());
    for(auto c : Pari)
        printf("%d ",c);
    printf("\n%d\n",Arya.size());
    for(auto c : Arya)
        printf("%d ",c);

}


#include <bits/stdc++.h>

using namespace std;
int n,m;
int color[100005];
int component[100005];
vector<int> G[100005];
vector<int> Pari , Arya;
vector<bool> visited(100005 , false);
bool not_bipartite = false;
map<int,int> count_comp;

void dfs(int u , int c , int comp) {
    visited[u] = true;
    color[u] = c;
    component[u] = comp;
    count_comp[comp]++;
    if(c == 1)
        c = 2;
    else
        c = 1;
    for(auto v : G[u]){
        if(!visited[v])
            dfs(v , c , comp);
        else{
            if(color[v] != c)
                not_bipartite = true;
        }
    }

}

int main(){
    cin >> n >> m;
    for(int i = 1 ; i )
    for(int i = 0 ; i < m ; ++i){
        int u , v;
        cin >> u >> v;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    int cnt = 1;
    for(int i = 1 ; i <= n ; ++i){
        if(!visited[i]){
            dfs(i , 1 , cnt);
            cnt++;
        }
    }
    if(not_bipartite){
        printf("-1");
        return 0;
    }
    for(int i = 1 ; i <= n ; ++i){
        if(component[i] == n_comp and color[i] == 1)
            Pari.push_back(i);
        if(component[i] == n_comp and color[i] == 2)
            Arya.push_back(i);
    }
    printf("%d\n",Pari.size());
    sort(Pari.begin(),Pari.end());
    sort(Arya.begin(),Arya.end());
    for(auto c : Pari)
        printf("%d ",c);
    printf("\n%d\n",Arya.size());
    for(auto c : Arya)
        printf("%d ",c);

}


#include <bits/stdc++.h>

using namespace std;
int n,m;
int color[100005];
int component[100005];
vector<int> G[100005];
vector<int> Pari , Arya;
vector<bool> visited(100005 , false);
bool not_bipartite = false;
map<int,int> count_comp;

void dfs(int u , int c , int comp) {
    visited[u] = true;
    color[u] = c;
    component[u] = comp;
    count_comp[comp]++;
    if(c == 1)
        c = 2;
    else
        c = 1;
    for(auto v : G[u]){
        if(!visited[v])
            dfs(v , c , comp);
        else{
            if(color[v] != c)
                not_bipartite = true;
        }
    }

}

int main(){
    cin >> n >> m;
    for(int i = 0 ; i < m ; ++i){
        int u , v;
        cin >> u >> v;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    int cnt = 1;
    for(int i = 1 ; i <= n ; ++i){
        if(!visited[i]){
            dfs(i , 1 , cnt);
            cnt++;
        }
    }
    if(not_bipartite){
        printf("-1");
        return 0;
    }
    for(auto c : count_comp){
        int n_comp = c.first;
        int cnt1 = 0 , cnt2 = 0;
        for(int i = 1 ; i <= n ; ++i){
            if(component[i] == n_comp and color[i] == 1)
                Pari.push_back(i);
        }
        for(int i = 1 ; i <= n ; ++i){
            if(component[i] == n_comp and color[i] == 2)
                Arya.push_back(i);
        }
    }
    printf("%d\n",Pari.size());
    sort(Pari.begin(),Pari.end());
    sort(Arya.begin(),Arya.end());
    for(auto c : Pari)
        printf("%d ",c);
    printf("\n%d\n",Arya.size());
    for(auto c : Arya)
        printf("%d ",c);

}


#include <bits/stdc++.h>

using namespace std;
int n,m;
int color[100005];
int component[100005];
vector<int> G[100005];
vector<bool> visited(100005 , false);
bool not_bipartite = false;
map<int,int> count_comp;

void dfs(int u , int c , int comp) {
    visited[u] = true;
    color[u] = c;
    component[u] = comp;
    count_comp[comp]++;
    if(c == 1)
        c = 2;
    else
        c = 1;
    for(auto v : G[u]){
        if(!visited[v])
            dfs(v , c , comp);
        else{
            if(color[v] != c)
                not_bipartite = true;
        }
    }

}

int main(){
    cin >> n >> m;
    for(int i = 0 ; i < m ; ++i){
        int u , v;
        cin >> u >> v;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    int cnt = 1;
    for(int i = 1 ; i <= n ; ++i){
        if(!visited[i]){
            dfs(i , 1 , cnt);
            cnt++;
        }
    }
    if(not_bipartite){
        printf("-1");
        return 0;
    }
    int mx = 0 , n_comp;
    for(auto c : count_comp){
        if(c.second > mx){
            mx = c.second;
            n_comp = c.first;
        }
    }
    int cnt1 = 0;
    for(int i = 1 ; i <= n ; ++i){
        if(component[i] == n_comp and color[i] == 1)
            cnt1++;
    }
    printf("%d\n",cnt1);
    for(int i = 1 ; i <= n ; ++i){
        if(component[i] == n_comp and color[i] == 1)
            printf("%d ",i);
    }
    printf("\n");
    int cnt2 = 0;
    for(int i = 1 ; i <= n ; ++i){
        if(component[i] == n_comp and color[i] == 2)
            cnt2++;
    }
    printf("%d\n",cnt2);
    for(int i = 1 ; i <= n ; ++i){
        if(component[i] == n_comp and color[i] == 2)
            printf("%d ",i);
    }
}


#include <bits/stdc++.h>
#include<string>
#include<vector>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;

#define INF INT_MAX
#define MOD 1000000007
vvi adj(100001);
vi a(100001);  //color 0
vi p(100001);  // color 1
vector<bool> visited(100001,false);

int bipartite(int u,int color)
{
   visited[u]=true;
   if(color==0)
      a[u]=1;
   else if(color==1)
      p[u]=1;

   for(int i=0;i<adj[u].size();i++)
   {
      if(!visited[adj[u][i]])
      {
         bipartite(adj[u][i],color^1);
      }
      else
      {
         if((color==0&&a[adj[u][i]]==1)||(color==1&&p[adj[u][i]]==1))
            return -1;

      }

   }

   return 1;
}

int main() {
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);
   int n,m;
   cin>>n>>m;
   int u,v;
   for(int i=1;i<=m;i++)
   {
      cin>>u>>v;
      adj[u].push_back(v);
      adj[v].push_back(u);
   }
   if(bipartite(1,0)==-1)
   cout<<-1<<endl;
   else
   {

      cout<<accumulate(p.begin(),p.end(),0)<<endl;
      for(int i=1;i<=n;i++)
         if(p[i]==1)
            cout<<i<<" ";
      cout<<endl;

      cout<<accumulate(a.begin(),a.end(),0)<<endl;
      for(int i=1;i<=n;i++)
         if(a[i]==1)
            cout<<i<<" ";
      cout<<endl;

   }
	// your code goes here
	return 0;
}


#include <bits/stdc++.h>
#include<string>
#include<vector>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;

#define INF INT_MAX
#define MOD 1000000007
vvi adj(100001);
vi a(100001);  //color 0
vi p(100001);  // color 1
vector<bool> visited(100001,false);

int bipartite(int u,int color)
{
   visited[u]=true;
   if(color==0)
      a[u]=1;
   else if(color==1)
      p[u]=1;

   for(int i=0;i<adj[u].size();i++)
   {
      if(!visited[adj[u][i]])
      {
         bipartite(adj[u][i],color^1);
      }
      else
      {
         if((color==0&&a[adj[u][i]]==1)||(color==1&&p[adj[u][i]]==1))
            return -1;

      }

   }

   return 1;
}

int main() {
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);
   int n,m;
   cin>>n>>m;
   int u,v;
   for(int i=1;i<=m;i++)
   {
      cin>>u>>v;
      adj[u].push_back(v);
      adj[v].push_back(u);
   }
   if(bipartite(1,0)==-1)
   cout<<-1<<endl;
   else
   {
      cout<<accumulate(p.begin(),p.end(),0)<<endl;
      cout<<accumulate(a.begin(),a.end(),0)<<endl;
      for(int i=1;i<=n;i++)
         if(p[i]==1)
            cout<<i<<" ";
      cout<<endl;

      for(int i=1;i<=n;i++)
         if(a[i]==1)
            cout<<i<<" ";

   }
	// your code goes here
	return 0;
}


#include <bits/stdc++.h>
#include<string>
#include<vector>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;

#define INF INT_MAX
#define MOD 1000000007
vvi adj(100001);
vi color(100001);

bool bipartite(int u,int c)
{

   color[u]=c;

   for(int i=0;i<adj[u].size();i++)
   {
      int v=adj[u][i];
      if(color[v]==-1)
      {
         return (bipartite(v,1-c));

      }
      else if(color[v]!=1-c)
      return false;
   }

   return true;
}

int main() {
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);
   int n,m,flag=0;
   cin>>n>>m;
   int u,v;
   for(int i=1;i<=m;i++)
   {
      cin>>u>>v;
      adj[u].push_back(v);
      adj[v].push_back(u);
   }
   for(int i=1;i<=n;i++)
   color[i]=-1;

   for(int i=1;i<=n;i++)
      if(color[i]==-1)
         if(bipartite(i,1)==false)
               {
                  cout<<-1<<endl;
                  return 0;
               }

   int sum=accumulate(color.begin(),color.end(),0);

   cout<<n-sum<<endl;
   for(int i=1;i<=n;i++)
      if(color[i]==0)
         cout<<i<<" ";
   cout<<endl;

   cout<<sum<<endl;
   for(int i=1;i<=n;i++)
      if(color[i]==1)
         cout<<i<<" ";
   cout<<endl;

	// your code goes here
	return 0;
}


#include <bits/stdc++.h>
#include<string>
#include<vector>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;

#define INF INT_MAX
#define MOD 1000000007

vvi adj(120000);
vvi c(2);
int mark[120000];

bool dfs(int u,int color=0)
{
   mark[u]=color;
   c[color].push_back(u);
   for(int i=0;i<adj[u].size();i++)
   {
      int v=adj[u][i];

      if(mark[v]==-1&&dfs(v,1-color))
         return true;

      else if(mark[v]!=1-color)
      return true;
   }
   return false;
}

int main() {
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);
   int n,m;
   cin>>n>>m;
   int u,v;
   for(int i=0;i<m;i++)
   {
      cin>>u>>v;
      u--;
      v--;
      adj[u].push_back(v);
      adj[v].push_back(u);
   }
   for(int i=0;i<n;i++)
   mark[i]=-1;

	for(int i=0;i<n;i++)
	{
	   if(mark[i]==-1)
	   {
	      if(adj[i].empty())
	         continue;

	     if(dfs(i))
	     {
	        cout<<-1<<endl;
	        return 0;
	     }
	   }
	}

	cout<<c[0].size()<<endl;
	for(int i=0;i<c[0].size();i++)
	   cout<<c[0][i]+1<<" ";
	  cout<<endl;

	cout<<c[1].size()<<endl;
	for(int i=0;i<c[1].size();i++)
	   cout<<c[1][i]+1<<" ";
	  cout<<endl;

	// your code goes here
	return 0;
}


#include <bits/stdc++.h>
#include<string>
#include<vector>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;

#define INF INT_MAX
#define MOD 1000000007
vvi adj(100001);
vi color(100001);

bool bipartite(int u,int c)
{
   if(color[u]!=-1&&color[u]!=c)
   return false;

   color[u]=c;

   for(int i=0;i<adj[u].size();i++)
   {
      int v=adj[u][i];
      if(color[v]==-1)
      {
         bipartite(v,1-c);
      }
      else if(color[v]!=1-c)
      return false;
   }

   return true;
}

int main() {
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);
   int n,m,flag=0;
   cin>>n>>m;
   int u,v;
   for(int i=1;i<=m;i++)
   {
      cin>>u>>v;
      adj[u].push_back(v);
      adj[v].push_back(u);
   }
   for(int i=1;i<=n;i++)
   color[i]=-1;

   for(int i=1;i<=n;i++)
      if(color[i]==-1)
         if(bipartite(i,1)==false)
            {
               flag=-1;
               break;
            }

if(flag==-1)
cout<<-1<<endl;
else
{
   int sum=accumulate(color.begin(),color.end(),0);

   cout<<n-sum<<endl;
   for(int i=1;i<=n;i++)
      if(color[i]==0)
         cout<<i<<" ";
   cout<<endl;

   cout<<sum<<endl;
   for(int i=1;i<=n;i++)
      if(color[i]==1)
         cout<<i<<" ";
   cout<<endl;

}
	// your code goes here
	return 0;
}


#include <bits/stdc++.h>
#include<string>
#include<vector>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;

#define INF INT_MAX
#define MOD 1000000007
vvi adj(100001);
vi color(100001);

bool bipartite(int u,int c)
{
   if(color[u]!=-1&&color[u]!=c)
   return false;

   color[u]=c;

   for(int i=0;i<adj[u].size();i++)
   {
      int v=adj[u][i];
      if(color[v]==-1)
      {
         return (bipartite(v,1-c));

      }
      else if(color[v]!=1-c)
      return false;
   }

   return true;
}

int main() {
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);
   int n,m,flag=0;
   cin>>n>>m;
   int u,v;
   for(int i=1;i<=m;i++)
   {
      cin>>u>>v;
      adj[u].push_back(v);
      adj[v].push_back(u);
   }
   for(int i=1;i<=n;i++)
   color[i]=-1;

   for(int i=1;i<=n;i++)
      if(color[i]==-1)
         if(bipartite(i,1)==false)
               {
                  cout<<-1<<endl;
                  return 0;
               }

   int sum=accumulate(color.begin(),color.end(),0);

   cout<<n-sum<<endl;
   for(int i=1;i<=n;i++)
      if(color[i]==0)
         cout<<i<<" ";
   cout<<endl;

   cout<<sum<<endl;
   for(int i=1;i<=n;i++)
      if(color[i]==1)
         cout<<i<<" ";
   cout<<endl;

	// your code goes here
	return 0;
}


#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<cstring>
#include<string>
//#include<unordered_map>
using namespace std;
const int maxn=1e5+50;
int n,m,ans;
vector<int>v[maxn],v1,v2;
int col[maxn];
bool bfs(int x)
{
    queue<int>q;
    memset(col,0,sizeof col);
    col[x]=1;
    q.push(x);
    while(!q.empty())
    {
        int u=q.front();
        q.pop();
        for(int i=0;i<v[u].size();++i)
        {
            int y=v[u][i];
            if(col[y]==0)
            {
                col[y]=-col[u];
                q.push(y);
            }
            else
            {
                if(col[y]==col[u]) return false;
            }
        }
    }
    return true;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>m;
    int s;
    for(int i=0;i<m;++i)
    {
         int x,y;
        cin>>x>>y;
        v[x].push_back(y);
        v[y].push_back(x);
        s=x;
    }
    for(int i=0;i<=n;++i)
    {
        if(v[i].size()&&col[i]==0)
        {
               if(!bfs(s))
               {
                     printf("-1\n");
                     return 0;
               }
        }
    }

        v1.clear();
        v2.clear();
        if(m==0) printf("0\n0\n");
        else
        {
            for(int i=1;i<=n;++i)
            {
                if(col[i]==-1) v1.push_back(i);
                else if(col[i]==1) v2.push_back(i);
            }
            cout<<v1.size()<<endl;
            for(int i=0;i<v1.size();++i)
            {
                    if(i!=0) printf(" ");
                    printf("%d",v1[i]);
            }
            printf("\n");
            cout<<v2.size()<<endl;
            for(int i=0;i<v2.size();++i)
            {
                if(i!=0) printf(" ");
                printf("%d",v2[i]);
            }
            printf("\n");
        }
    return 0;
}


#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<cstring>
#include<string>
//#include<unordered_map>
using namespace std;
const int maxn=1e5+50;
int n,m,ans;
vector<int>v[maxn],v1,v2;
int col[maxn];
bool bfs(int x)
{
    queue<int>q;
    memset(col,0,sizeof col);
    col[x]=1;
    q.push(x);
    while(!q.empty())
    {
        int u=q.front();
        q.pop();
        for(int i=0;i<v[u].size();++i)
        {
            int y=v[u][i];
            if(col[y]==0)
            {
                col[y]=-col[u];
                q.push(y);
            }
            else
            {
                if(col[y]==col[u]) return false;
            }
        }
    }
    return true;
}
int main()
{
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    cin>>n>>m;
    int s;
    for(int i=0;i<m;++i)
    {
         int x,y;
        cin>>x>>y;
        v[x].push_back(y);
        v[y].push_back(x);
        s=x;
    }
    for(int i=0;i<=n;++i)
    {
        if(v[i].size()&&col[i]==0)
        {
               if(!bfs(s))
               {
                     printf("-1\n");
                     return 0;
               }
        }
    }

        v1.clear();
        v2.clear();
        if(m==0) printf("0\n0\n");
        else
        {
            for(int i=1;i<=n;++i)
            {
                if(col[i]==-1) v1.push_back(i);
                else if(col[i]==1) v2.push_back(i);
            }
            cout<<v1.size()<<endl;
            for(int i=0;i<v1.size();++i)
            {
                    if(i!=0) printf(" ");
                    printf("%d",v1[i]);
            }
            printf("\n");
            cout<<v2.size()<<endl;
            for(int i=0;i<v2.size();++i)
            {
                if(i!=0) printf(" ");
                printf("%d",v2[i]);
            }
            printf("\n");
        }
    return 0;
}


#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<cstring>
#include<string>
//#include<unordered_map>
using namespace std;
const int maxn=1e5+50;
int n,m,ans;
vector<int>v[maxn],v1,v2;
int col[maxn];
bool bfs(int x)
{
    queue<int>q;
    //memset(col,0,sizeof col);
    col[x]=1;
    q.push(x);
    while(!q.empty())
    {
        int u=q.front();
        q.pop();
        for(int i=0;i<v[u].size();++i)
        {
            int y=v[u][i];
            if(col[y]==0)
            {
                col[y]=-col[u];
                q.push(y);
            }
            else
            {
                if(col[y]==col[u]) return false;
            }
        }
    }
    return true;
}
int main()
{
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    cin>>n>>m;
    int s;
    memset(col,0,sizeof col);
    for(int i=0;i<m;++i)
    {
         int x,y;
        cin>>x>>y;
        v[x].push_back(y);
        v[y].push_back(x);
        s=x;
    }
    for(int i=0;i<=n;++i)
    {
        if(v[i].size()&&col[i]==0)
        {
               if(!bfs(s))
               {
                     printf("-1\n");
                     return 0;
               }
        }
    }

        v1.clear();
        v2.clear();
        if(m==0) printf("0\n0\n");
        else
        {
            for(int i=1;i<=n;++i)
            {
                if(col[i]==-1) v1.push_back(i);
                else if(col[i]==1) v2.push_back(i);
            }
            cout<<v1.size()<<endl;
            for(int i=0;i<v1.size();++i)
            {
                    if(i!=0) printf(" ");
                    printf("%d",v1[i]);
            }
            printf("\n");
            cout<<v2.size()<<endl;
            for(int i=0;i<v2.size();++i)
            {
                if(i!=0) printf(" ");
                printf("%d",v2[i]);
            }
            printf("\n");
        }
    return 0;
}


#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<cstring>
#include<string>
//#include<unordered_map>
using namespace std;
const int maxn=1e5+50;
int n,m,ans;
vector<int>v[maxn],v1,v2;
int col[maxn];
bool bfs(int x)
{
    queue<int>q;
    //memset(col,0,sizeof col);
    col[x]=1;
    q.push(x);
    while(!q.empty())
    {
        int u=q.front();
        q.pop();
        for(int i=0;i<v[u].size();++i)
        {
            int y=v[u][i];
            if(col[y]==0)
            {
                col[y]=-col[u];
                q.push(y);
            }
            else
            {
                if(col[y]==col[u]) return false;
            }
        }
    }
    return true;
}
int main()
{
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    cin>>n>>m;
    int s;
    memset(col,0,sizeof col);
    for(int i=0;i<m;++i)
    {
         int x,y;
        cin>>x>>y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    for(int i=0;i<=n;++i)
    {
        if(v[i].size()&&col[i]==0)
        {
               if(!bfs(i))
               {
                     printf("-1\n");
                     return 0;
               }
        }
    }

        v1.clear();
        v2.clear();
        if(m==0) printf("0\n0\n");
        else
        {
            for(int i=1;i<=n;++i)
            {
                if(col[i]==-1) v1.push_back(i);
                else if(col[i]==1) v2.push_back(i);
            }
            cout<<v1.size()<<endl;
            for(int i=0;i<v1.size();++i)
            {
                    if(i!=0) printf(" ");
                    printf("%d",v1[i]);
            }
            printf("\n");
            cout<<v2.size()<<endl;
            for(int i=0;i<v2.size();++i)
            {
                if(i!=0) printf(" ");
                printf("%d",v2[i]);
            }
            printf("\n");
        }
    return 0;
}


#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<cstring>
#include<string>
//#include<unordered_map>
using namespace std;
const int maxn=1e5+50;
int n,m,ans;
vector<int>v[maxn],v1,v2;
int col[maxn];
bool bfs(int x)
{
    queue<int>q;
    memset(col,0,sizeof col);
    col[x]=1;
    q.push(x);
    while(!q.empty())
    {
        int u=q.front();
        q.pop();
        for(int i=0;i<v[u].size();++i)
        {
            int y=v[u][i];
            if(col[y]==0)
            {
                col[y]=-col[u];
                q.push(y);
            }
            else
            {
                if(col[y]==col[u]) return false;
            }
        }
    }
    return true;
}
int main()
{
    ios::sync_with_stdio(false);
    //cin.tie(0);
    cin>>n>>m;
    int s;
    for(int i=0;i<m;++i)
    {
         int x,y;
        cin>>x>>y;
        v[x].push_back(y);
        v[y].push_back(x);
        s=x;
    }
    for(int i=0;i<=n;++i)
    {
        if(v[i].size()&&col[i]==0)
        {
               if(!bfs(s))
               {
                     printf("-1\n");
                     return 0;
               }
        }
    }

        v1.clear();
        v2.clear();
        if(m==0) printf("0\n0\n");
        else
        {
            for(int i=1;i<=n;++i)
            {
                if(col[i]==-1) v1.push_back(i);
                else if(col[i]==1) v2.push_back(i);
            }
            cout<<v1.size()<<endl;
            for(int i=0;i<v1.size();++i)
            {
                    if(i!=0) printf(" ");
                    printf("%d",v1[i]);
            }
            printf("\n");
            cout<<v2.size()<<endl;
            for(int i=0;i<v2.size();++i)
            {
                if(i!=0) printf(" ");
                printf("%d",v2[i]);
            }
            printf("\n");
        }
    return 0;
}


/*
*author: rits1272
*/
#include<bits/stdc++.h>
using namespace std;

#define pb push_back
#define F first
#define S second
#define MAX 1e9
#define MIN -1e9
#define INF 1e18
#define MOD 1000000007
#define int long long
#define FOR(x, n) for(int i=x; i<n; i++)
#define print(x) cout << "[" << #x << ":" << x << "] ";
#define println(x) cout << "[" << #x << ":" << x << "]\n";

int dx[8] = { -1, 0, 0, 1, -1, -1, 1, 1 };
int dy[8] = { 0, 1, -1, 0, -1, 1, -1, 1 };
double PI = acos(-1);

const int mxN = 100000 + 5;
vector<int> adj[mxN];
vector<int> color[2];
int mark[mxN];
int n, m;

bool dfs(int u, int c = 2){
	mark[u] = c;
	color[c-1].pb(u);
	for(int v: adj[u]){
		if(!mark[v] && dfs(v, 3-c))
			return 1;
		if(mark[v] != 3-c)
			return 1;
	}
	return 0;
}

int32_t main(){
	ios::sync_with_stdio(0);
    cin.tie(0);
	#ifndef ONLINE_JUDGE
		freopen("in.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	#endif
	cin >> n >> m;
	for(int i=0; i<m; i++){
		int a, b; cin >> a >> b;
		--a, --b;
		adj[a].pb(b);
		adj[b].pb(a);
	}

	for(int i=0; i<n; i++){
		if(!mark[i]){
			if(adj[i].empty())
				continue;
			if(dfs(i)){
				cout << -1 << "\n";
				return 0;
			}
		}
	}

	for(int i=0; i<2; i++){
		cout << color[i].size() << "\n";
		for(int c: color[i]){
			cout << c+1 << " ";
		}
		cout << '\n';
	}
	return 0;
}


/*
*author: rits1272
*/
#include<bits/stdc++.h>
using namespace std;

#define pb push_back
#define F first
#define S second
#define MAX 1e9
#define MIN -1e9
#define INF 1e18
#define MOD 1000000007
#define int long long
#define FOR(x, n) for(int i=x; i<n; i++)
#define print(x) cout << "[" << #x << ":" << x << "] ";
#define println(x) cout << "[" << #x << ":" << x << "]\n";

int dx[8] = { -1, 0, 0, 1, -1, -1, 1, 1 };
int dy[8] = { 0, 1, -1, 0, -1, 1, -1, 1 };
double PI = acos(-1);

const int mxN = 100000 + 1;
vector<int> adj[mxN];
vector<int> color(mxN, -1);
vector<int> mark[mxN];
vector<bool> vis(mxN, false);
int n, m;

void dfs(int u){
	vis[u] = true;
	for(int v: adj[u]){
		if(!vis[v]){
			color[v] = 1 - color[u];
			// print(u) print(color[u]) print(v) println(color[v])
			mark[color[v]].pb(v);
			dfs(v);
		}
		else if(vis[v] && color[v] == color[u]){
			cout << -1 << "\n";
			exit(0);
		}
	}
	return;
}

int32_t main(){
	ios::sync_with_stdio(0);
    cin.tie(0);
	#ifndef ONLINE_JUDGE
		freopen("in.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	#endif
	cin >> n >> m;
	for(int i=0; i<m; i++){
		int a, b; cin >> a >> b;
		adj[a].pb(b);
		adj[b].pb(a);
	}

	color[1] = 0;
	mark[0].pb(1);
	for(int i=1; i<=n; i++){
		if(!vis[i])
			dfs(i);
	}

	for(int i=0; i<2; i++){
		cout << mark[i].size() << "\n";
		for(int c: mark[i]){
			cout << c << " ";
		}
		cout << '\n';
	}
	return 0;
}


/*
*author: rits1272
*/
#include<bits/stdc++.h>
using namespace std;

#define pb push_back
#define F first
#define S second
#define MAX 1e9
#define MIN -1e9
#define INF 1e18
#define MOD 1000000007
#define int long long
#define FOR(x, n) for(int i=x; i<n; i++)
#define print(x) cout << "[" << #x << ":" << x << "] ";
#define println(x) cout << "[" << #x << ":" << x << "]\n";

int dx[8] = { -1, 0, 0, 1, -1, -1, 1, 1 };
int dy[8] = { 0, 1, -1, 0, -1, 1, -1, 1 };
double PI = acos(-1);

const int mxN = 100000 + 1000;
vector<int> adj[mxN];
vector<int> color(mxN, -1);
vector<int> mark[2];
vector<bool> vis(mxN, false);
int n, m;

void dfs(int u){
	vis[u] = true;
	for(int v: adj[u]){
		if(!vis[v]){
			color[v] = 1 - color[u];
			// print(u) print(color[u]) print(v) println(color[v])
			mark[color[v]].pb(v);
			dfs(v);
		}
		else if(vis[v] && color[v] == color[u]){
			cout << -1 << "\n";
			exit(0);
		}
	}
	return;
}

int32_t main(){
	ios::sync_with_stdio(0);
    cin.tie(0);
	#ifndef ONLINE_JUDGE
		freopen("in.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	#endif
	cin >> n >> m;
	for(int i=0; i<m; i++){
		int a, b; cin >> a >> b;
		adj[a].pb(b);
		adj[b].pb(a);
	}

	color[1] = 0;
	mark[0].pb(1);
	for(int i=1; i<=n; i++){
		if(!vis[i])
			dfs(i);
	}

	for(int i=0; i<2; i++){
		cout << mark[i].size() << "\n";
		for(int c: mark[i]){
			cout << c << " ";
		}
		cout << '\n';
	}
	return 0;
}


/*
*author: rits1272
*/
#include<bits/stdc++.h>
using namespace std;

#define pb push_back
#define F first
#define S second
#define MAX 1e9
#define MIN -1e9
#define INF 1e18
#define MOD 1000000007
#define int long long
#define FOR(x, n) for(int i=x; i<n; i++)
#define print(x) cout << "[" << #x << ":" << x << "] ";
#define println(x) cout << "[" << #x << ":" << x << "]\n";

int dx[8] = { -1, 0, 0, 1, -1, -1, 1, 1 };
int dy[8] = { 0, 1, -1, 0, -1, 1, -1, 1 };
double PI = acos(-1);

const int mxN = 100000 + 1000;
vector<int> adj[mxN];
vector<int> color(mxN, -1);
vector<int> mark[mxN];
vector<bool> vis(mxN, false);
int n, m;

void dfs(int u){
	vis[u] = true;
	for(int v: adj[u]){
		if(!vis[v]){
			color[v] = 1 - color[u];
			// print(u) print(color[u]) print(v) println(color[v])
			mark[color[v]].pb(v);
			dfs(v);
		}
		else if(vis[v] && color[v] == color[u]){
			cout << -1 << "\n";
			exit(0);
		}
	}
	return;
}

int32_t main(){
	ios::sync_with_stdio(0);
    cin.tie(0);
	#ifndef ONLINE_JUDGE
		freopen("in.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	#endif
	cin >> n >> m;
	for(int i=0; i<m; i++){
		int a, b; cin >> a >> b;
		adj[a].pb(b);
		adj[b].pb(a);
	}

	color[1] = 0;
	mark[0].pb(1);
	for(int i=1; i<=n; i++){
		if(!vis[i])
			dfs(i);
	}

	for(int i=0; i<2; i++){
		cout << mark[i].size() << "\n";
		for(int c: mark[i]){
			cout << c << " ";
		}
		cout << '\n';
	}
	return 0;
}


/*
*author: rits1272
*/
#include<bits/stdc++.h>
using namespace std;

#define pb push_back
#define F first
#define S second
#define MAX 1e9
#define MIN -1e9
#define INF 1e18
#define MOD 1000000007
#define int long long
#define FOR(x, n) for(int i=x; i<n; i++)
#define print(x) cout << "[" << #x << ":" << x << "] ";
#define println(x) cout << "[" << #x << ":" << x << "]\n";

int dx[8] = { -1, 0, 0, 1, -1, -1, 1, 1 };
int dy[8] = { 0, 1, -1, 0, -1, 1, -1, 1 };
double PI = acos(-1);

const int mxN = 100000;
vector<int> adj[mxN];
vector<int> color(mxN, -1);
vector<int> mark[mxN];
vector<bool> vis(mxN, false);
int n, m;

void dfs(int u){
	vis[u] = true;
	for(int v: adj[u]){
		if(!vis[v]){
			color[v] = 1 - color[u];
			mark[1-color[u]].pb(v);
			dfs(v);
		}
		else if(color[v] == color[u]){
			cout << -1 << "\n";
			exit(0);
		}
	}
	return;
}

int32_t main(){
	ios::sync_with_stdio(0);
    cin.tie(0);
	#ifndef ONLINE_JUDGE
		freopen("in.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	#endif
	cin >> n >> m;
	for(int i=0; i<m; i++){
		int a, b; cin >> a >> b;
		--a, --b;
		adj[a].pb(b);
		adj[b].pb(a);
	}

	color[0] = 0;
	for(int i=0; i<n; i++){
		if(!vis[i])
			dfs(i);
	}

	for(int i=0; i<2; i++){
		cout << mark[i].size() << "\n";
		for(int c: mark[i]){
			cout << c + 1 << " ";
		}
		cout << '\n';
	}
	return 0;
}


/*
*author: rits1272
*/
#include<bits/stdc++.h>
using namespace std;

#define pb push_back
#define F first
#define S second
#define MAX 1e9
#define MIN -1e9
#define INF 1e18
#define MOD 1000000007
#define int long long
#define FOR(x, n) for(int i=x; i<n; i++)
#define print(x) cout << "[" << #x << ":" << x << "] ";
#define println(x) cout << "[" << #x << ":" << x << "]\n";

int dx[8] = { -1, 0, 0, 1, -1, -1, 1, 1 };
int dy[8] = { 0, 1, -1, 0, -1, 1, -1, 1 };
double PI = acos(-1);

const int mxN = 100000 + 1000;
vector<int> adj[mxN];
vector<int> color(mxN, -1);
vector<int> mark[2];
vector<bool> vis(mxN, false);
int n, m;

void dfs(int u){
	vis[u] = true;
	for(int v: adj[u]){
		if(!vis[v]){
			color[v] = !color[u];
			// print(u) print(color[u]) print(v) println(color[v])
			mark[color[v]].pb(v);
			dfs(v);
		}
		else if(color[v] == color[u]){
			cout << -1 << "\n";
			exit(0);
		}
	}
	return;
}

int32_t main(){
	ios::sync_with_stdio(0);
    cin.tie(0);
	#ifndef ONLINE_JUDGE
		freopen("in.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	#endif
	cin >> n >> m;
	for(int i=0; i<m; i++){
		int a, b; cin >> a >> b;
		adj[a].pb(b);
		adj[b].pb(a);
	}

	color[1] = 0;
	mark[0].pb(1);
	for(int i=1; i<=n; i++){
		if(!vis[i])
			dfs(i);
	}

	for(int i=0; i<2; i++){
		cout << mark[i].size() << "\n";
		for(int c: mark[i]){
			cout << c << " ";
		}
		cout << '\n';
	}
	return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <vector>
#define MAXL 1299710
#define ll long long
#define inf 0x7f7f7f7f
using namespace std;
const int maxn= 1e5+7;
const ll mod=9999999967;
struct node
{
    int to,w,next;
} edge[maxn<<1];
int head[maxn],d[maxn],color[maxn];
int cnt=0;
int f;
void add(int u,int v)
{
    edge[cnt].to=v;
    edge[cnt].next=head[u];
    head[u]=cnt++;
}
void dfs(int x,int fa)
{
    if(f==1)
        return  ;

    for(int i=head[x]; i!=-1; i=edge[i].next)
    {
        int v=edge[i].to;
        if(fa==v)
            continue;
        if(color[x]==color[v])
        {
            f=1;
            return  ;
        }
        if(!color[v])
        {
            color[v]=3-color[x];
            dfs(v,x);

        }

    }

}
int main()
{
    int n,m,u,v;
    scanf("%d%d",&n,&m);
    for(int i=1; i<=n; i++)
    {
        head[i]=-1;
    }
    for(int i=1; i<=m; i++)
    {
        scanf("%d%d",&u,&v);
        add(u,v);
        add(v,u);
    }
    for(int i=1; i<=n; i++)
    {
        if(!color[i])
        {
            if(head[i]==-1)
                continue;

            f=0;
            color[i]=1;
            dfs(i,0);
            if(f)
            {
                cout<<"-1"<<endl;
                return 0;
            }
        }
    }
    int ans1=0,ans2=0;
    for(int i=1; i<=n; i++)
    {
        if(color[i]==1)
            ans1++;
        if(color[i]==2)
            ans2++;
    }
    cout<<ans1<<endl;
    for(int i=1; i<=n; i++)
        if(color[i]==1)
            cout<<i<<" ";
    cout<<endl<<ans2<<endl;
    for(int i=1; i<=n; i++)
        if(color[i]==2)
            cout<<i<<" ";

    return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <vector>
#define MAXL 1299710
#define ll long long
#define inf 0x7f7f7f7f
using namespace std;
const int maxn= 1e6+7;
const ll mod=9999999967;
struct node
{
    int to,w,next;
} edge[maxn<<1];
int head[maxn],d[maxn],color[maxn];
int cnt=0;
int f;
void add(int u,int v)
{
    edge[cnt].to=v;
    edge[cnt].next=head[u];
    head[u]=cnt++;
}
void dfs(int x,int fa)
{
    if(color[x]==color[fa])
    {
        f=1;
        return;
    }
    for(int i=head[x]; i!=-1; i=edge[i].next)
    {
        int v=edge[i].to;
        if(fa==v)
            continue;

        if(!color[v])
        {
            color[v]=3-color[x];
        }
        dfs(v,x);
    }
}
int main()
{
    int n,m,u,v;
    cin>>n>>m;
    for(int i=1; i<=n; i++)
    {
        head[i]=-1;
    }
    for(int i=1; i<=m; i++)
    {
        cin>>u>>v;
        add(u,v);
        add(v,u);
    }
    for(int i=1; i<=n; i++)
    {
        if(!color[i])
        {
            if(head[i]==-1)
            continue;

              f=0;
            color[i]=1;
            dfs(i,0);
            if(f)
            {
                cout<<"-1"<<endl;
                return 0;
            }
        }
    }
    int ans1=0,ans2=0;
    for(int i=1; i<=n; i++)
    {
        if(color[i]==1)
            ans1++;
        if(color[i]==2)
            ans2++;
    }
    cout<<ans1<<endl;
    for(int i=1;i<=n;i++)
        if(color[i]==1)
        cout<<i<<" ";
    cout<<endl<<ans2<<endl;
 for(int i=1;i<=n;i++)
        if(color[i]==2)
        cout<<i<<" ";

    return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <vector>
#define MAXL 1299710
#define ll long long
#define inf 0x7f7f7f7f
using namespace std;
const int maxn= 1e5+7;
const ll mod=9999999967;
struct node
{
    int to,w,next;
} edge[maxn<<1];
int head[maxn],d[maxn],color[maxn];
int cnt=0;
int f;
void add(int u,int v)
{
    edge[cnt].to=v;
    edge[cnt].next=head[u];
    head[u]=cnt++;
}
bool dfs(int x,int fa)
{
    if(f==1)
        return 0;

    for(int i=head[x]; i!=-1; i=edge[i].next)
    {
        int v=edge[i].to;
        if(fa==v)
            continue;
        if(color[x]==color[v])
        {
            f=1;
            return 0;
        }
        if(!color[v])
        {
            color[v]=3-color[x];
              if(!dfs(v,x))
            return 0;
        }

    }
    return 1;
}
int main()
{
    int n,m,u,v;
    scanf("%d%d",&n,&m);
    for(int i=1; i<=n; i++)
    {
        head[i]=-1;
    }
    for(int i=1; i<=m; i++)
    {
        scanf("%d%d",&u,&v);
        add(u,v);
        add(v,u);
    }
    for(int i=1; i<=n; i++)
    {
        if(!color[i])
        {
            if(head[i]==-1)
                continue;

            f=0;
            color[i]=1;
            dfs(i,0);
            if(f)
            {
                cout<<"-1"<<endl;
                return 0;
            }
        }
    }
    int ans1=0,ans2=0;
    for(int i=1; i<=n; i++)
    {
        if(color[i]==1)
            ans1++;
        if(color[i]==2)
            ans2++;
    }
    cout<<ans1<<endl;
    for(int i=1; i<=n; i++)
        if(color[i]==1)
            cout<<i<<" ";
    cout<<endl<<ans2<<endl;
    for(int i=1; i<=n; i++)
        if(color[i]==2)
            cout<<i<<" ";

    return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <vector>
#define MAXL 1299710
#define ll long long
#define inf 0x7f7f7f7f
using namespace std;
const int maxn= 1e6+7;
const ll mod=9999999967;
struct node
{
    int to,w,next;
} edge[maxn<<1];
int head[maxn],d[maxn],color[maxn];
int cnt=0;
int f;
void add(int u,int v)
{
    edge[cnt].to=v;
    edge[cnt].next=head[u];
    head[u]=cnt++;
}
void dfs(int x,int fa)
{
    if(f==1)
        return;

    for(int i=head[x]; i!=-1; i=edge[i].next)
    {
        int v=edge[i].to;
        if(fa==v)
            continue;
        if(color[x]==color[v])
        {
            f=1;
            return;
        }
        if(!color[v])
        {
            color[v]=3-color[x];
        }
        dfs(v,x);
    }
}
int main()
{
    int n,m,u,v;
    scanf("%d%d",&n,&m);
    for(int i=1; i<=n; i++)
    {
        head[i]=-1;
    }
    for(int i=1; i<=m; i++)
    {
        scanf("%d%d",&u,&v);
        add(u,v);
        add(v,u);
    }
    for(int i=1; i<=n; i++)
    {
        if(!color[i])
        {
            if(head[i]==-1)
                continue;

            f=0;
            color[i]=1;
            dfs(i,0);
            if(f)
            {
                cout<<"-1"<<endl;
                return 0;
            }
        }
    }
    int ans1=0,ans2=0;
    for(int i=1; i<=n; i++)
    {
        if(color[i]==1)
            ans1++;
        if(color[i]==2)
            ans2++;
    }
    cout<<ans1<<endl;
    for(int i=1; i<=n; i++)
        if(color[i]==1)
            cout<<i<<" ";
    cout<<endl<<ans2<<endl;
    for(int i=1; i<=n; i++)
        if(color[i]==2)
            cout<<i<<" ";

    return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <vector>
#define MAXL 1299710
#define ll long long
#define inf 0x7f7f7f7f
using namespace std;
const int maxn= 1e5+7;
const ll mod=9999999967;
struct node
{
    int to,w,next;
} edge[maxn<<1];
int head[maxn],d[maxn],color[maxn];
int cnt=0;
int f;
void add(int u,int v)
{
    edge[cnt].to=v;
    edge[cnt].next=head[u];
    head[u]=cnt++;
}
void dfs(int x,int fa)
{
    if(f==1)
        return  ;
    if(color[x]==color[fa])
        {
            f=1;
            return  ;
        }
    for(int i=head[x]; i!=-1; i=edge[i].next)
    {
        int v=edge[i].to;
        if(fa==v)
            continue;

        if(!color[v])
        {
            color[v]=3-color[x];
             dfs(v,x);

        }

    }

}
int main()
{
    int n,m,u,v;
    scanf("%d%d",&n,&m);
    for(int i=1; i<=n; i++)
    {
        head[i]=-1;
    }
    for(int i=1; i<=m; i++)
    {
        scanf("%d%d",&u,&v);
        add(u,v);
        add(v,u);
    }
    for(int i=1; i<=n; i++)
    {
        if(!color[i])
        {
            if(head[i]==-1)
                continue;

            f=0;
            color[i]=1;
            dfs(i,0);
            if(f)
            {
                cout<<"-1"<<endl;
                return 0;
            }
        }
    }
    int ans1=0,ans2=0;
    for(int i=1; i<=n; i++)
    {
        if(color[i]==1)
            ans1++;
        if(color[i]==2)
            ans2++;
    }
    cout<<ans1<<endl;
    for(int i=1; i<=n; i++)
        if(color[i]==1)
            cout<<i<<" ";
    cout<<endl<<ans2<<endl;
    for(int i=1; i<=n; i++)
        if(color[i]==2)
            cout<<i<<" ";

    return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <vector>
#define MAXL 1299710
#define ll long long
#define inf 0x7f7f7f7f
using namespace std;
const int maxn= 1e6+7;
const ll mod=9999999967;
struct node
{
    int to,w,next;
} edge[maxn<<1];
int head[maxn],d[maxn],color[maxn];
int cnt=0;
int f;
void add(int u,int v)
{
    edge[cnt].to=v;
    edge[cnt].next=head[u];
    head[u]=cnt++;
}
bool dfs(int x,int fa)
{
    if(f==1)
        return 0;

    for(int i=head[x]; i!=-1; i=edge[i].next)
    {
        int v=edge[i].to;
        if(fa==v)
            continue;
        if(color[x]==color[v])
        {
            f=1;
            return 0;
        }
        if(!color[v])
        {
            color[v]=3-color[x];
        }
        if(!dfs(v,x))
            return 0;
    }
    return 1;
}
int main()
{
    int n,m,u,v;
    scanf("%d%d",&n,&m);
    for(int i=1; i<=n; i++)
    {
        head[i]=-1;
    }
    for(int i=1; i<=m; i++)
    {
        scanf("%d%d",&u,&v);
        add(u,v);
        add(v,u);
    }
    for(int i=1; i<=n; i++)
    {
        if(!color[i])
        {
            if(head[i]==-1)
                continue;

            f=0;
            color[i]=1;
            dfs(i,0);
            if(f)
            {
                cout<<"-1"<<endl;
                return 0;
            }
        }
    }
    int ans1=0,ans2=0;
    for(int i=1; i<=n; i++)
    {
        if(color[i]==1)
            ans1++;
        if(color[i]==2)
            ans2++;
    }
    cout<<ans1<<endl;
    for(int i=1; i<=n; i++)
        if(color[i]==1)
            cout<<i<<" ";
    cout<<endl<<ans2<<endl;
    for(int i=1; i<=n; i++)
        if(color[i]==2)
            cout<<i<<" ";

    return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <vector>
#define MAXL 1299710
#define ll long long
#define inf 0x7f7f7f7f
using namespace std;
const int maxn= 1e5+7;
const ll mod=9999999967;
struct node
{
    int to,w,next;
} edge[maxn<<1];
int head[maxn],d[maxn],color[maxn];
int cnt=0;
int f;
void add(int u,int v)
{
    edge[cnt].to=v;
    edge[cnt].next=head[u];
    head[u]=cnt++;
}
void dfs(int x,int fa)
{
    if(color[x]==color[fa])
    {
        f=1;
        return;
    }
    for(int i=head[x]; i!=-1; i=edge[i].next)
    {
        int v=edge[i].to;
        if(fa==v)
            continue;

        if(!color[v])
        {
            color[v]=3-color[x];
        }
        dfs(v,x);
    }
}
int main()
{
    int n,m,u,v;
    cin>>n>>m;
    for(int i=1; i<=n; i++)
    {
        head[i]=-1;
    }
    for(int i=1; i<=m; i++)
    {
        cin>>u>>v;
        add(u,v);
        add(v,u);
    }
    for(int i=1; i<=n; i++)
    {
        if(!color[i])
        {
            if(head[i]==-1)
            continue;

              f=0;
            color[i]=1;
            dfs(i,0);
            if(f)
            {
                cout<<"-1"<<endl;
                return 0;
            }
        }
    }
    int ans1=0,ans2=0;
    for(int i=1; i<=n; i++)
    {
        if(color[i]==1)
            ans1++;
        if(color[i]==2)
            ans2++;
    }
    cout<<ans1<<endl;
    for(int i=1;i<=n;i++)
        if(color[i]==1)
        cout<<i<<" ";
    cout<<endl<<ans2<<endl;
 for(int i=1;i<=n;i++)
        if(color[i]==2)
        cout<<i<<" ";

    return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <vector>
#define MAXL 1299710
#define ll long long
#define inf 0x7f7f7f7f
using namespace std;
const int maxn= 1e6+7;
const ll mod=9999999967;
struct node
{
    int to,w,next;
} edge[maxn<<1];
int head[maxn],d[maxn],color[maxn];
int cnt=0;
int f;
void add(int u,int v)
{
    edge[cnt].to=v;
    edge[cnt].next=head[u];
    head[u]=cnt++;
}
void dfs(int x,int fa)
{
    if(f==1)
        return;
    if(color[x]==color[fa])
    {
        f=1;
        return;
    }
    for(int i=head[x]; i!=-1; i=edge[i].next)
    {
        int v=edge[i].to;
        if(fa==v)
            continue;

        if(!color[v])
        {
            color[v]=3-color[x];
        }
        dfs(v,x);
    }
}
int main()
{
    int n,m,u,v;
        scanf("%d%d",&n,&m);
    for(int i=1; i<=n; i++)
    {
        head[i]=-1;
    }
    for(int i=1; i<=m; i++)
    {
       scanf("%d%d",&u,&v);
        add(u,v);
        add(v,u);
    }
    for(int i=1; i<=n; i++)
    {
        if(!color[i])
        {
            if(head[i]==-1)
            continue;

              f=0;
            color[i]=1;
            dfs(i,0);
            if(f)
            {
                cout<<"-1"<<endl;
                return 0;
            }
        }
    }
    int ans1=0,ans2=0;
    for(int i=1; i<=n; i++)
    {
        if(color[i]==1)
            ans1++;
        if(color[i]==2)
            ans2++;
    }
    cout<<ans1<<endl;
    for(int i=1;i<=n;i++)
        if(color[i]==1)
        cout<<i<<" ";
    cout<<endl<<ans2<<endl;
 for(int i=1;i<=n;i++)
        if(color[i]==2)
        cout<<i<<" ";

    return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <vector>
#define MAXL 1299710
#define ll long long
#define inf 0x7f7f7f7f
using namespace std;
const int maxn= 1e5+7;
const ll mod=9999999967;
struct node
{
    int to,w,next;
} edge[maxn<<1];
int head[maxn],d[maxn],color[maxn];
int cnt=0;
int f;
void add(int u,int v)
{
    edge[cnt].to=v;
    edge[cnt].next=head[u];
    head[u]=cnt++;
}
bool dfs(int x,int fa)
{
    if(f==1)
        return 0;

    for(int i=head[x]; i!=-1; i=edge[i].next)
    {
        int v=edge[i].to;
        if(fa==v)
            continue;
        if(color[x]==color[v])
        {
            f=1;
            return 0;
        }
        if(!color[v])
        {
            color[v]=3-color[x];
        }
        if(!dfs(v,x))
            return 0;
    }
    return 1;
}
int main()
{
    int n,m,u,v;
    scanf("%d%d",&n,&m);
    for(int i=1; i<=n; i++)
    {
        head[i]=-1;
    }
    for(int i=1; i<=m; i++)
    {
        scanf("%d%d",&u,&v);
        add(u,v);
        add(v,u);
    }
    for(int i=1; i<=n; i++)
    {
        if(!color[i])
        {
            if(head[i]==-1)
                continue;

            f=0;
            color[i]=1;
            dfs(i,0);
            if(f)
            {
                cout<<"-1"<<endl;
                return 0;
            }
        }
    }
    int ans1=0,ans2=0;
    for(int i=1; i<=n; i++)
    {
        if(color[i]==1)
            ans1++;
        if(color[i]==2)
            ans2++;
    }
    cout<<ans1<<endl;
    for(int i=1; i<=n; i++)
        if(color[i]==1)
            cout<<i<<" ";
    cout<<endl<<ans2<<endl;
    for(int i=1; i<=n; i++)
        if(color[i]==2)
            cout<<i<<" ";

    return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <vector>
#define MAXL 1299710
#define ll long long
#define inf 0x7f7f7f7f
using namespace std;
const int maxn= 1e6+7;
const ll mod=9999999967;
struct node
{
    int to,w,next;
} edge[maxn];
int head[maxn],d[maxn],color[maxn];
int cnt=0;
int f;
void add(int u,int v)
{
    edge[cnt].to=v;
    edge[cnt].next=head[u];
    head[u]=cnt++;
}
void dfs(int x,int fa)
{
    if(color[x]==color[fa])
    {
        f=1;
        return;
    }
    for(int i=head[x]; i!=-1; i=edge[i].next)
    {
        int v=edge[i].to;
        if(fa==v)
            continue;

        if(!color[v])
        {
            color[v]=3-color[x];
        }
        dfs(v,x);
    }
}
int main()
{
    int n,m,u,v;
    cin>>n>>m;
    for(int i=1; i<=n; i++)
    {
        head[i]=-1;
    }
    for(int i=1; i<=m; i++)
    {
        cin>>u>>v;
        add(u,v);
        add(v,u);
    }
    for(int i=1; i<=n; i++)
    {
        if(!color[i])
        {
            if(head[i]==-1)
            continue;

              f=0;
            color[i]=1;
            dfs(i,0);
            if(f)
            {
                cout<<"-1"<<endl;
                return 0;
            }
        }
    }
    int ans1=0,ans2=0;
    for(int i=1; i<=n; i++)
    {
        if(color[i]==1)
            ans1++;
        if(color[i]==2)
            ans2++;
    }
    cout<<ans1<<endl;
    for(int i=1;i<=n;i++)
        if(color[i]==1)
        cout<<i<<" ";
    cout<<endl<<ans2<<endl;
 for(int i=1;i<=n;i++)
        if(color[i]==2)
        cout<<i<<" ";

    return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <vector>
#define MAXL 1299710
#define ll long long
#define inf 0x7f7f7f7f
using namespace std;
const int maxn= 1e6+7;
const ll mod=9999999967;
struct node
{
    int to,w,next;
} edge[maxn<<1];
int head[maxn],d[maxn],color[maxn];
int cnt=0;
int f;
void add(int u,int v)
{
    edge[cnt].to=v;
    edge[cnt].next=head[u];
    head[u]=cnt++;
}
void dfs(int x,int fa)
{
    if(f==1)
        return;
    if(color[x]==color[fa])
    {
        f=1;
        return;
    }
    for(int i=head[x]; i!=-1; i=edge[i].next)
    {
        int v=edge[i].to;
        if(fa==v)
            continue;

        if(!color[v])
        {
            color[v]=3-color[x];
        }
        dfs(v,x);
    }
}
int main()
{
    int n,m,u,v;
    cin>>n>>m;
    for(int i=1; i<=n; i++)
    {
        head[i]=-1;
    }
    for(int i=1; i<=m; i++)
    {
        cin>>u>>v;
        add(u,v);
        add(v,u);
    }
    for(int i=1; i<=n; i++)
    {
        if(!color[i])
        {
            if(head[i]==-1)
            continue;

              f=0;
            color[i]=1;
            dfs(i,0);
            if(f)
            {
                cout<<"-1"<<endl;
                return 0;
            }
        }
    }
    int ans1=0,ans2=0;
    for(int i=1; i<=n; i++)
    {
        if(color[i]==1)
            ans1++;
        if(color[i]==2)
            ans2++;
    }
    cout<<ans1<<endl;
    for(int i=1;i<=n;i++)
        if(color[i]==1)
        cout<<i<<" ";
    cout<<endl<<ans2<<endl;
 for(int i=1;i<=n;i++)
        if(color[i]==2)
        cout<<i<<" ";

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ld long double
#define ll long long
#define rem 1000000007

typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<ll, ll> pii;
#define v(x) vector<x>
#define pb(x) push_back(x)
#define ppb() pop_back()
#define mp(x,y) make_pair(x,y)
#define mii map<ll,ll>
#define umii unordered_map<ll,ll>
#define mxheap priority_queue<ll> // Max Heap
#define mnheap priority_queue<ll,vi,greater<ll> > // Min Heap
#define da(type,arr,size) type *arr = new type[n] // Dynamically allocated array

#define f(i,n) for(ll i=0;i<(n);i++)
#define fa(i,a,b) for(ll i=(a);i<(b);i++)
#define far(i,a,b) for(ll i=(a);i>(b);i--)
#define T ll t; cin>>t; while(t--)
#define ff first
#define ss second
#define mem(a,b) memset(a,b,sizeof(a))
#define sz size()

#define setbits(x) __builtin_popcountll(x) // Total set bits in a number
#define zerobits(x) __builtin_ctzll(x) // This will tell me number of zeroes till first set bit
#define all(c) (c).begin(),(c).end()
#define setp(x,y) fixed<<setprecision(y)<<x
#define fast ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define INF 2e18

// ld dist(ll x1, ll y1, ll x2, ll y2) {
// 	ld ans = round(pow(mod(x2 - x1), 2)) + round(pow(mod(y2 - y1), 2));
// 	ans = sqrt(ans);
// 	return ans;
// }

// ld dist(pii a, pii b) {
// 	ld ans = round(pow(mod(b.ff - a.ff), 2)) + round(pow(mod(b.ss - a.ss), 2));
// 	ans = sqrt(ans);
// 	return ans;
// }
// umii isPrime;
// void SieveOfEratosthenes(ll n)
// {
// 	bool prime[n + 1];
// 	memset(prime, true, sizeof(prime));

// 	for (ll p = 2; p * p <= n; p++)
// 	{
// 		if (prime[p] == true)
// 		{
// 			for (ll i = p * p; i <= n; i += p)
// 				prime[i] = false;
// 		}
// 	}
// 	for (ll p = 2; p <= n; p++)
// 		if (prime[p])
// 			isPrime[p] = 1;;
// }
// ll binaryToDecimal(vi& num)
// {
// 	//string num = n;
// 	ll dec_value = 0;

// 	// Initializing base value to 1, i.e 2^0
// 	ll base = 1;

// 	ll len = num.size();
// 	for (ll i = 0; i < len; i++) {
// 		if (num[i] == 1)
// 			dec_value += base;
// 		base = base * 2;
// 	}

// 	return dec_value;
// }

ll power_mod(ll x, ll y, ll p)
{
	ll res = 1;     // Initialize result

	x = x % p; // Update x if it is more than or
	// equal to p

	if (x == 0) return 0; // In case x is divisible by p;

	while (y > 0)
	{
		// If y is odd, multiply x with result
		if (y & 1)
			res = (res * x) % p;

		// y must be even now
		y = y >> 1; // y = y/2
		x = (x * x) % p;
	}
	return res;
}

ll power(ll x, ll y) {
	ll res = 1;
	while (y) {
		if (y % 2 == 1) {
			res *= x;
			y--;
		}
		else {
			x *= (x);
			y /= 2;
		}
	}
	return res;
}

// ll sq(ll n) {
// 	return (n * n);
// }

// ll gcdExtended(ll a, ll b, ll *x, ll *y);

// // Function to find modulo inverse of a
// ll modInverse(ll a, ll m)
// {
// 	ll x, y;
// 	ll g = gcdExtended(a, m, &x, &y);
// 	ll res = (x % m + m) % m;
// 	return res;

// }

// ll gcdExtended(ll a, ll b, ll *x, ll *y)
// {
// 	// Base Case
// 	if (a == 0)
// 	{
// 		*x = 0, *y = 1;
// 		return b;
// 	}

// 	ll x1, y1; // To store results of recursive call
// 	ll gcd = gcdExtended(b % a, a, &x1, &y1);

// 	// Update x and y using results of recursive
// 	// call
// 	*x = y1 - (b / a) * x1;
// 	*y = x1;

// 	return gcd;
// }

void primeFactors(ll n, umii& mp)
{
	unordered_map<ll, bool> lop;
	while (n % 2 == 0)
	{
		lop[2] = 1;
		n = n / 2;
	}
	for (ll i = 3; i <= sqrt(n); i = i + 2)
	{
		while (n % i == 0)
		{
			lop[i] = 1;
			n = n / i;
		}
	}
	if (n > 2)
		lop[n] = 1;
	for (auto it : lop) {
		if (it.ss) {
			mp[it.ff]++;
		}
	}
}

// void decToBinary(ll n, vi& binaryNum)
// {
// 	ll i = 0;
// 	while (n > 0) {
// 		binaryNum[i] = n % 2;
// 		n = n / 2;
// 		i++;
// 	}
// }

// ll getAns(umii& a, umii& c) {
// 	umii kitne;
// 	for (auto it : c) {
// 		if (it.ss % 2 == 1) {
// 			return -1;
// 		}
// 		kitne[it.ff] = it.ss / 2;
// 	}
// 	vi aMeAyega;
// 	for (auto it : kitne) {
// 		ll diff = mod(it.ss - a[it.ff]);
// 		f(i, diff) {
// 			aMeAyega.pb(it.ff);
// 		}

// 	}
// 	ll ans = 0;
// 	sort(all(aMeAyega));

// 	f(i, aMeAyega.sz / 2) {
// 		ans += aMeAyega[i];
// 	}
// 	return ans;
// }
ll gcd(ll a, ll b) {
	return __gcd(a, b);
}

// ll factMod(ll n) {
// 	ll ans = 1;
// 	fa(i, 1, n + 1) {
// 		ans *= i;
// 		ans %= rem;
// 	}
// 	return ans;
// }

// string numToString(ll num){
// 	string ans = "";
// 	while(num){
// 		ll temp = num%10;
// 		ans+=to_string(temp%2);
// 		num/=2;
// 	}
// 	while(ans.sz!=18){
// 		ans+='0';
// 	}
// 	reverse(ans.begin(),ans.end());
// 	return ans;
// }

// void SieveOfEratosthenes(ll n, umii& mp)
// {
// 	// Create a boolean array "prime[0..n]" and initialize
// 	// all entries it as true. A value in prime[i] will
// 	// finally be false if i is Not a prime, else true.
// 	bool prime[n + 1];
// 	memset(prime, true, sizeof(prime));

// 	for (int p = 2; p * p <= n; p++)
// 	{
// 		// If prime[p] is not changed, then it is a prime
// 		if (prime[p] == true)
// 		{
// 			// Update all multiples of p greater than or
// 			// equal to the square of it
// 			// numbers which are multiple of p and are
// 			// less than p^2 are already been marked.
// 			for (int i = p * p; i <= n; i += p)
// 				prime[i] = false;
// 		}
// 	}

// 	// Print all prime numbers
// 	for (int p = 2; p <= n; p++)
// 		if (prime[p])
// 			mp[p]++;
// }

// void printDivisors(ll n, umii& mp)
// {
// 	// Note that this loop runs till square root
// 	for (ll i = 1; i <= sqrt(n); i++)
// 	{
// 		if (n % i == 0)
// 		{
// 			// If divisors are equal, print only one
// 			if (n / i == i) {
// 				mp[i]++;
// 			}

// 			else // Otherwise print both
// 				mp[i]++, mp[n / i]++;
// 		}
// 	}
// }

bool dfs(ll src, unordered_map<ll, vi>& adjList, vector<bool>& visited, ll level, vi& set1, vi& set2, vi& parent, vector<ll>& valueForVertex, ll value) {
	visited[src] = true;
	valueForVertex[src] = value;
	if (level % 2 == 0) {
		set1.pb(src);
	}
	else {
		set2.pb(src);
	}
	bool ans = true;
	for (ll j : adjList[src]) {
		if (visited[j] && j != parent[src]) {
			if ((value - valueForVertex[j]) % 2 == 0)
				return false;
		}
		else if (!visited[j]) {
			parent[j] = src;
			ans &= dfs(j, adjList, visited, level + 1, set1, set2, parent, valueForVertex, value + 1);
		}
	}
	return ans;
}

int main() {
	fast
	ll n, m;
	cin >> n >> m;
	unordered_map<ll, vi> adjList;
	f(i, m) {
		ll u, v;
		cin >> u >> v;
		adjList[u].pb(v);
		adjList[v].pb(u);
	}
	std::vector<bool> visited(n + 1, false);
	vi parent(n + 1);
	f(i, n + 1) parent[i] = i;
	vector<ll> set1;
	vector<ll> set2;
	vector<ll> valueForVertex(n + 1, -1);
	bool ans = true;
	for (ll i = 1; i <= n; i++)
		if (!visited[i]) {
			ans &= dfs(i, adjList, visited, 0, set1, set2, parent, valueForVertex, 0);
			if (!ans) break;
		}
	if (!ans)
		cout << -1 << endl;
	else {
		cout << set1.sz << endl;
		f(i, set1.sz) {
			cout << set1[i] << " ";
		}
		cout << endl;
		cout << set2.sz << endl;
		f(i, set2.sz) {
			cout << set2[i] << " ";
		}
		cout << endl;
	}
	return 0;
}


#include <iostream>
#include <vector>
#include <unordered_set>
#include<bits/stdc++.h>
using namespace std;

bool bipartite(vector<int>* edges, int n) {
	if (n == 0) {
		return true;
	}
	unordered_set<int> sets[2];
	vector<int> pending;
	sets[0].insert(1);
	pending.push_back(1);
	while (pending.size() > 0) {
		int current = pending.back();
		pending.pop_back();
		int currentSet = sets[0].count(current) > 0 ? 0 : 1;
		for (int i = 0; i < edges[current].size(); i++) {
			int neighbor = edges[current][i];
			if (sets[0].count(neighbor) == 0 && sets[1].count(neighbor) == 0) {
				sets[1 - currentSet].insert(neighbor);
				pending.push_back(neighbor);
			} else if (sets[currentSet].count(neighbor) > 0) {
				return false;
			}
		}
	}
	cout<<sets[0].size()<<endl;
	for(auto it : sets[0]){
	    cout<<it<<" ";
	}
	cout<<endl;
	cout<<sets[1].size()<<endl;
	for(auto it : sets[1]){
	    cout<<it<<" ";
	}
	return true;
}

int main() {
		int n;
		cin >> n;
		vector<int>* edges = new vector<int>[n+1];
		int m;
		cin >> m;
		for (int i = 0; i < m; i++) {
			int j, k;
			cin >> j >> k;
			edges[j].push_back(k);
			edges[k].push_back(j);
		}
		bool ans = bipartite(edges, n);
		delete [] edges;
		if (ans) {
			return 0;
		} else {
			cout << -1 << endl;
		}

}


#include <bits/stdc++.h>
using namespace std;
#define ld long double
#define ll long long
#define rem 1000000007

typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<ll, ll> pii;
#define v(x) vector<x>
#define pb(x) push_back(x)
#define ppb() pop_back()
#define mp(x,y) make_pair(x,y)
#define mii map<ll,ll>
#define umii unordered_map<ll,ll>
#define mxheap priority_queue<ll> // Max Heap
#define mnheap priority_queue<ll,vi,greater<ll> > // Min Heap
#define da(type,arr,size) type *arr = new type[n] // Dynamically allocated array

#define f(i,n) for(ll i=0;i<(n);i++)
#define fa(i,a,b) for(ll i=(a);i<(b);i++)
#define far(i,a,b) for(ll i=(a);i>(b);i--)
#define T ll t; cin>>t; while(t--)
#define ff first
#define ss second
#define mem(a,b) memset(a,b,sizeof(a))
#define sz size()

#define setbits(x) __builtin_popcountll(x) // Total set bits in a number
#define zerobits(x) __builtin_ctzll(x) // This will tell me number of zeroes till first set bit
#define all(c) (c).begin(),(c).end()
#define setp(x,y) fixed<<setprecision(y)<<x
#define fast ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define INF 2e18

// ld dist(ll x1, ll y1, ll x2, ll y2) {
// 	ld ans = round(pow(mod(x2 - x1), 2)) + round(pow(mod(y2 - y1), 2));
// 	ans = sqrt(ans);
// 	return ans;
// }

// ld dist(pii a, pii b) {
// 	ld ans = round(pow(mod(b.ff - a.ff), 2)) + round(pow(mod(b.ss - a.ss), 2));
// 	ans = sqrt(ans);
// 	return ans;
// }
// umii isPrime;
// void SieveOfEratosthenes(ll n)
// {
// 	bool prime[n + 1];
// 	memset(prime, true, sizeof(prime));

// 	for (ll p = 2; p * p <= n; p++)
// 	{
// 		if (prime[p] == true)
// 		{
// 			for (ll i = p * p; i <= n; i += p)
// 				prime[i] = false;
// 		}
// 	}
// 	for (ll p = 2; p <= n; p++)
// 		if (prime[p])
// 			isPrime[p] = 1;;
// }
// ll binaryToDecimal(vi& num)
// {
// 	//string num = n;
// 	ll dec_value = 0;

// 	// Initializing base value to 1, i.e 2^0
// 	ll base = 1;

// 	ll len = num.size();
// 	for (ll i = 0; i < len; i++) {
// 		if (num[i] == 1)
// 			dec_value += base;
// 		base = base * 2;
// 	}

// 	return dec_value;
// }

ll power_mod(ll x, ll y, ll p)
{
	ll res = 1;     // Initialize result

	x = x % p; // Update x if it is more than or
	// equal to p

	if (x == 0) return 0; // In case x is divisible by p;

	while (y > 0)
	{
		// If y is odd, multiply x with result
		if (y & 1)
			res = (res * x) % p;

		// y must be even now
		y = y >> 1; // y = y/2
		x = (x * x) % p;
	}
	return res;
}

ll power(ll x, ll y) {
	ll res = 1;
	while (y) {
		if (y % 2 == 1) {
			res *= x;
			y--;
		}
		else {
			x *= (x);
			y /= 2;
		}
	}
	return res;
}

// ll sq(ll n) {
// 	return (n * n);
// }

// ll gcdExtended(ll a, ll b, ll *x, ll *y);

// // Function to find modulo inverse of a
// ll modInverse(ll a, ll m)
// {
// 	ll x, y;
// 	ll g = gcdExtended(a, m, &x, &y);
// 	ll res = (x % m + m) % m;
// 	return res;

// }

// ll gcdExtended(ll a, ll b, ll *x, ll *y)
// {
// 	// Base Case
// 	if (a == 0)
// 	{
// 		*x = 0, *y = 1;
// 		return b;
// 	}

// 	ll x1, y1; // To store results of recursive call
// 	ll gcd = gcdExtended(b % a, a, &x1, &y1);

// 	// Update x and y using results of recursive
// 	// call
// 	*x = y1 - (b / a) * x1;
// 	*y = x1;

// 	return gcd;
// }

void primeFactors(ll n, umii& mp)
{
	unordered_map<ll, bool> lop;
	while (n % 2 == 0)
	{
		lop[2] = 1;
		n = n / 2;
	}
	for (ll i = 3; i <= sqrt(n); i = i + 2)
	{
		while (n % i == 0)
		{
			lop[i] = 1;
			n = n / i;
		}
	}
	if (n > 2)
		lop[n] = 1;
	for (auto it : lop) {
		if (it.ss) {
			mp[it.ff]++;
		}
	}
}

// void decToBinary(ll n, vi& binaryNum)
// {
// 	ll i = 0;
// 	while (n > 0) {
// 		binaryNum[i] = n % 2;
// 		n = n / 2;
// 		i++;
// 	}
// }

// ll getAns(umii& a, umii& c) {
// 	umii kitne;
// 	for (auto it : c) {
// 		if (it.ss % 2 == 1) {
// 			return -1;
// 		}
// 		kitne[it.ff] = it.ss / 2;
// 	}
// 	vi aMeAyega;
// 	for (auto it : kitne) {
// 		ll diff = mod(it.ss - a[it.ff]);
// 		f(i, diff) {
// 			aMeAyega.pb(it.ff);
// 		}

// 	}
// 	ll ans = 0;
// 	sort(all(aMeAyega));

// 	f(i, aMeAyega.sz / 2) {
// 		ans += aMeAyega[i];
// 	}
// 	return ans;
// }
ll gcd(ll a, ll b) {
	return __gcd(a, b);
}

// ll factMod(ll n) {
// 	ll ans = 1;
// 	fa(i, 1, n + 1) {
// 		ans *= i;
// 		ans %= rem;
// 	}
// 	return ans;
// }

// string numToString(ll num){
// 	string ans = "";
// 	while(num){
// 		ll temp = num%10;
// 		ans+=to_string(temp%2);
// 		num/=2;
// 	}
// 	while(ans.sz!=18){
// 		ans+='0';
// 	}
// 	reverse(ans.begin(),ans.end());
// 	return ans;
// }

// void SieveOfEratosthenes(ll n, umii& mp)
// {
// 	// Create a boolean array "prime[0..n]" and initialize
// 	// all entries it as true. A value in prime[i] will
// 	// finally be false if i is Not a prime, else true.
// 	bool prime[n + 1];
// 	memset(prime, true, sizeof(prime));

// 	for (int p = 2; p * p <= n; p++)
// 	{
// 		// If prime[p] is not changed, then it is a prime
// 		if (prime[p] == true)
// 		{
// 			// Update all multiples of p greater than or
// 			// equal to the square of it
// 			// numbers which are multiple of p and are
// 			// less than p^2 are already been marked.
// 			for (int i = p * p; i <= n; i += p)
// 				prime[i] = false;
// 		}
// 	}

// 	// Print all prime numbers
// 	for (int p = 2; p <= n; p++)
// 		if (prime[p])
// 			mp[p]++;
// }

// void printDivisors(ll n, umii& mp)
// {
// 	// Note that this loop runs till square root
// 	for (ll i = 1; i <= sqrt(n); i++)
// 	{
// 		if (n % i == 0)
// 		{
// 			// If divisors are equal, print only one
// 			if (n / i == i) {
// 				mp[i]++;
// 			}

// 			else // Otherwise print both
// 				mp[i]++, mp[n / i]++;
// 		}
// 	}
// }

bool dfs(ll src, unordered_map<ll, vi>& adjList, vector<bool>& visited, ll level, vi& set1, vi& set2, vi& parent, vector<ll>& valueForVertex, ll value) {
	visited[src] = true;
	valueForVertex[src] = value;
	if (level % 2 == 0) {
		set1.pb(src);
	}
	else {
		set2.pb(src);
	}
	bool ans = true;
	for (ll j : adjList[src]) {
		if (visited[j] && j != parent[src]) {
			if ((value - valueForVertex[j]) % 2 == 0)
				return false;
		}
		else if (!visited[j]) {
			parent[j] = src;
			ans &= dfs(j, adjList, visited, level + 1, set1, set2, parent, valueForVertex, value + 1);
		}
	}
	return ans;
}

int main() {
	fast
	ll n, m;
	cin >> n >> m;
	unordered_map<ll, vi> adjList;
	f(i, m) {
		ll u, v;
		cin >> u >> v;
		adjList[u].pb(v);
		adjList[v].pb(u);
	}
	std::vector<bool> visited(n + 1, false);
	vi parent(n + 1);
	f(i, n + 1) parent[i] = i;
	vector<ll> set1;
	vector<ll> set2;
	vector<ll> valueForVertex(n + 1, -1);
	bool ans = true;
	for (ll i = 1; i <= n; i++)
		if (!visited[i]) {
			ans &= dfs(1, adjList, visited, 0, set1, set2, parent, valueForVertex, 0);
			if (!ans) break;
		}
	if (!ans)
		cout << -1 << endl;
	else {
		sort(all(set1));
		sort(all(set2));
		cout << set1.sz << endl;
		f(i, set1.sz) {
			cout << set1[i] << " ";
		}
		cout << endl;
		cout << set2.sz << endl;
		f(i, set2.sz) {
			cout << set2[i] << " ";
		}
		cout << endl;
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

inline int in() { int x; scanf("%d", &x); return x; }
const int N = 120021;

vector <int> vc[2];
vector <int> g[N];
int mark[N];

bool dfs(int v, int color = 2)
{
	mark[v] = color;
	vc[color - 1].push_back(v);
	for(int u : g[v])
	{
		if(!mark[u] && dfs(u, 3 - color))
				return 1;
		if(mark[u] != 3 - color)
			return 1;
	}
	return 0;
}

int main()
{
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < m; i++)
	{
		int u = in() - 1;
		int v = in() - 1;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	for(int i = 0; i < n; i++)
		if(!mark[i])
		{
		     if(g[i].empty())
		          continue;
		     if(dfs(i))
			{
				cout << -1 << endl;
				return 0;
			}
		}
	for(int i = 0; i < 2; i++)
	{
		cout << vc[i].size() << endl;
		for(int v : vc[i])
			cout << v + 1 << " ";
		cout << endl;
	}
}


#include <bits/stdc++.h>
using namespace std;
#define ld long double
#define ll long long
#define rem 1000000007

typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<ll, ll> pii;
#define v(x) vector<x>
#define pb(x) push_back(x)
#define ppb() pop_back()
#define mp(x,y) make_pair(x,y)
#define mii map<ll,ll>
#define umii unordered_map<ll,ll>
#define mxheap priority_queue<ll> // Max Heap
#define mnheap priority_queue<ll,vi,greater<ll> > // Min Heap
#define da(type,arr,size) type *arr = new type[n] // Dynamically allocated array

#define f(i,n) for(ll i=0;i<(n);i++)
#define fa(i,a,b) for(ll i=(a);i<(b);i++)
#define far(i,a,b) for(ll i=(a);i>(b);i--)
#define T ll t; cin>>t; while(t--)
#define ff first
#define ss second
#define mem(a,b) memset(a,b,sizeof(a))
#define sz size()

#define setbits(x) __builtin_popcountll(x) // Total set bits in a number
#define zerobits(x) __builtin_ctzll(x) // This will tell me number of zeroes till first set bit
#define all(c) (c).begin(),(c).end()
#define setp(x,y) fixed<<setprecision(y)<<x
#define fast ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define INF 2e18

// ld dist(ll x1, ll y1, ll x2, ll y2) {
// 	ld ans = round(pow(mod(x2 - x1), 2)) + round(pow(mod(y2 - y1), 2));
// 	ans = sqrt(ans);
// 	return ans;
// }

// ld dist(pii a, pii b) {
// 	ld ans = round(pow(mod(b.ff - a.ff), 2)) + round(pow(mod(b.ss - a.ss), 2));
// 	ans = sqrt(ans);
// 	return ans;
// }
// umii isPrime;
// void SieveOfEratosthenes(ll n)
// {
// 	bool prime[n + 1];
// 	memset(prime, true, sizeof(prime));

// 	for (ll p = 2; p * p <= n; p++)
// 	{
// 		if (prime[p] == true)
// 		{
// 			for (ll i = p * p; i <= n; i += p)
// 				prime[i] = false;
// 		}
// 	}
// 	for (ll p = 2; p <= n; p++)
// 		if (prime[p])
// 			isPrime[p] = 1;;
// }
// ll binaryToDecimal(vi& num)
// {
// 	//string num = n;
// 	ll dec_value = 0;

// 	// Initializing base value to 1, i.e 2^0
// 	ll base = 1;

// 	ll len = num.size();
// 	for (ll i = 0; i < len; i++) {
// 		if (num[i] == 1)
// 			dec_value += base;
// 		base = base * 2;
// 	}

// 	return dec_value;
// }

ll power_mod(ll x, ll y, ll p)
{
	ll res = 1;     // Initialize result

	x = x % p; // Update x if it is more than or
	// equal to p

	if (x == 0) return 0; // In case x is divisible by p;

	while (y > 0)
	{
		// If y is odd, multiply x with result
		if (y & 1)
			res = (res * x) % p;

		// y must be even now
		y = y >> 1; // y = y/2
		x = (x * x) % p;
	}
	return res;
}

ll power(ll x, ll y) {
	ll res = 1;
	while (y) {
		if (y % 2 == 1) {
			res *= x;
			y--;
		}
		else {
			x *= (x);
			y /= 2;
		}
	}
	return res;
}

// ll sq(ll n) {
// 	return (n * n);
// }

// ll gcdExtended(ll a, ll b, ll *x, ll *y);

// // Function to find modulo inverse of a
// ll modInverse(ll a, ll m)
// {
// 	ll x, y;
// 	ll g = gcdExtended(a, m, &x, &y);
// 	ll res = (x % m + m) % m;
// 	return res;

// }

// ll gcdExtended(ll a, ll b, ll *x, ll *y)
// {
// 	// Base Case
// 	if (a == 0)
// 	{
// 		*x = 0, *y = 1;
// 		return b;
// 	}

// 	ll x1, y1; // To store results of recursive call
// 	ll gcd = gcdExtended(b % a, a, &x1, &y1);

// 	// Update x and y using results of recursive
// 	// call
// 	*x = y1 - (b / a) * x1;
// 	*y = x1;

// 	return gcd;
// }

void primeFactors(ll n, umii& mp)
{
	unordered_map<ll, bool> lop;
	while (n % 2 == 0)
	{
		lop[2] = 1;
		n = n / 2;
	}
	for (ll i = 3; i <= sqrt(n); i = i + 2)
	{
		while (n % i == 0)
		{
			lop[i] = 1;
			n = n / i;
		}
	}
	if (n > 2)
		lop[n] = 1;
	for (auto it : lop) {
		if (it.ss) {
			mp[it.ff]++;
		}
	}
}

// void decToBinary(ll n, vi& binaryNum)
// {
// 	ll i = 0;
// 	while (n > 0) {
// 		binaryNum[i] = n % 2;
// 		n = n / 2;
// 		i++;
// 	}
// }

// ll getAns(umii& a, umii& c) {
// 	umii kitne;
// 	for (auto it : c) {
// 		if (it.ss % 2 == 1) {
// 			return -1;
// 		}
// 		kitne[it.ff] = it.ss / 2;
// 	}
// 	vi aMeAyega;
// 	for (auto it : kitne) {
// 		ll diff = mod(it.ss - a[it.ff]);
// 		f(i, diff) {
// 			aMeAyega.pb(it.ff);
// 		}

// 	}
// 	ll ans = 0;
// 	sort(all(aMeAyega));

// 	f(i, aMeAyega.sz / 2) {
// 		ans += aMeAyega[i];
// 	}
// 	return ans;
// }
ll gcd(ll a, ll b) {
	return __gcd(a, b);
}

// ll factMod(ll n) {
// 	ll ans = 1;
// 	fa(i, 1, n + 1) {
// 		ans *= i;
// 		ans %= rem;
// 	}
// 	return ans;
// }

// string numToString(ll num){
// 	string ans = "";
// 	while(num){
// 		ll temp = num%10;
// 		ans+=to_string(temp%2);
// 		num/=2;
// 	}
// 	while(ans.sz!=18){
// 		ans+='0';
// 	}
// 	reverse(ans.begin(),ans.end());
// 	return ans;
// }

// void SieveOfEratosthenes(ll n, umii& mp)
// {
// 	// Create a boolean array "prime[0..n]" and initialize
// 	// all entries it as true. A value in prime[i] will
// 	// finally be false if i is Not a prime, else true.
// 	bool prime[n + 1];
// 	memset(prime, true, sizeof(prime));

// 	for (int p = 2; p * p <= n; p++)
// 	{
// 		// If prime[p] is not changed, then it is a prime
// 		if (prime[p] == true)
// 		{
// 			// Update all multiples of p greater than or
// 			// equal to the square of it
// 			// numbers which are multiple of p and are
// 			// less than p^2 are already been marked.
// 			for (int i = p * p; i <= n; i += p)
// 				prime[i] = false;
// 		}
// 	}

// 	// Print all prime numbers
// 	for (int p = 2; p <= n; p++)
// 		if (prime[p])
// 			mp[p]++;
// }

// void printDivisors(ll n, umii& mp)
// {
// 	// Note that this loop runs till square root
// 	for (ll i = 1; i <= sqrt(n); i++)
// 	{
// 		if (n % i == 0)
// 		{
// 			// If divisors are equal, print only one
// 			if (n / i == i) {
// 				mp[i]++;
// 			}

// 			else // Otherwise print both
// 				mp[i]++, mp[n / i]++;
// 		}
// 	}
// }

bool dfs(ll src, unordered_map<ll, vi>& adjList, vector<bool>& visited, ll level, vi& set1, vi& set2, vi& parent, vector<ll>& valueForVertex, ll value) {
	visited[src] = true;
	valueForVertex[src] = value;
	if (level % 2 == 0) {
		set1.pb(src);
	}
	else {
		set2.pb(src);
	}
	bool ans = true;
	for (ll j : adjList[src]) {
		if (visited[j] && j != parent[src]) {
			if ((value - valueForVertex[j]) % 2 == 0)
				return false;
		}
		else if (!visited[j]) {
			parent[j] = src;
			ans &= dfs(j, adjList, visited, level + 1, set1, set2, parent, valueForVertex, value + 1);
		}
	}
	return ans;
}

int main() {
	fast
	ll n, m;
	cin >> n >> m;
	unordered_map<ll, vi> adjList;
	f(i, m) {
		ll u, v;
		cin >> u >> v;
		adjList[u].pb(v);
		adjList[v].pb(u);
	}
	std::vector<bool> visited(n + 1, false);
	vi parent(n + 1);
	f(i, n + 1) parent[i] = i;
	vector<ll> set1;
	vector<ll> set2;
	vector<ll> valueForVertex(n + 1, -1);
	bool ans = dfs(1, adjList, visited, 0, set1, set2, parent, valueForVertex, 0);
	if (!ans)
		cout << -1 << endl;
	else {
		cout << set1.sz << endl;
		f(i, set1.sz) {
			cout << set1[i] << " ";
		}
		cout << endl;
		cout << set2.sz << endl;
		f(i, set2.sz) {
			cout << set2[i] << " ";
		}
		cout << endl;
	}
	return 0;
}


#include <iostream>
#include <vector>
#include <unordered_set>
using namespace std;

bool bipartite(vector<int>* edges, int n) {
	if (n == 0) {
		return true;
	}
	unordered_set<int> sets[2];
	vector<int> pending;
	sets[0].insert(1);
	pending.push_back(1);
	while (pending.size() > 0) {
		int current = pending.back();
		pending.pop_back();
		int currentSet = sets[0].count(current) > 0 ? 0 : 1;
		for (int i = 0; i < edges[current].size(); i++) {
			int neighbor = edges[current][i];
			if (sets[0].count(neighbor) == 0 && sets[1].count(neighbor) == 0) {
				sets[1 - currentSet].insert(neighbor);
				pending.push_back(neighbor);
			} else if (sets[currentSet].count(neighbor) > 0) {
				return false;
			}
		}
	}
	cout<<sets[0].size()<<endl;
	for(auto it : sets[0]){
	    cout<<it<<" ";
	}
	cout<<endl;
	cout<<sets[1].size()<<endl;
	for(auto it : sets[1]){
	    cout<<it<<" ";
	}
	return true;
}

int main() {
	while (true) {
		int n;
		cin >> n;
		if (n == 0)
			break;
		vector<int>* edges = new vector<int>[n+1];
		int m;
		cin >> m;
		for (int i = 0; i < m; i++) {
			int j, k;
			cin >> j >> k;
			edges[j].push_back(k);
			edges[k].push_back(j);
		}
		bool ans = bipartite(edges, n);
		delete [] edges;
		if (ans) {
			return 0;
		} else {
			cout << -1 << endl;
		}
	}
}


#include <bits/stdc++.h>
using namespace std;
#define ld long double
#define ll long long
#define rem 1000000007

typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<ll, ll> pii;
#define v(x) vector<x>
#define pb(x) push_back(x)
#define ppb() pop_back()
#define mp(x,y) make_pair(x,y)
#define mii map<ll,ll>
#define umii unordered_map<ll,ll>
#define mxheap priority_queue<ll> // Max Heap
#define mnheap priority_queue<ll,vi,greater<ll> > // Min Heap
#define da(type,arr,size) type *arr = new type[n] // Dynamically allocated array

#define f(i,n) for(ll i=0;i<(n);i++)
#define fa(i,a,b) for(ll i=(a);i<(b);i++)
#define far(i,a,b) for(ll i=(a);i>(b);i--)
#define T ll t; cin>>t; while(t--)
#define ff first
#define ss second
#define mem(a,b) memset(a,b,sizeof(a))
#define sz size()

#define setbits(x) __builtin_popcountll(x) // Total set bits in a number
#define zerobits(x) __builtin_ctzll(x) // This will tell me number of zeroes till first set bit
#define all(c) (c).begin(),(c).end()
#define setp(x,y) fixed<<setprecision(y)<<x
#define fast ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define INF 2e18

// ld dist(ll x1, ll y1, ll x2, ll y2) {
// 	ld ans = round(pow(mod(x2 - x1), 2)) + round(pow(mod(y2 - y1), 2));
// 	ans = sqrt(ans);
// 	return ans;
// }

// ld dist(pii a, pii b) {
// 	ld ans = round(pow(mod(b.ff - a.ff), 2)) + round(pow(mod(b.ss - a.ss), 2));
// 	ans = sqrt(ans);
// 	return ans;
// }
// umii isPrime;
// void SieveOfEratosthenes(ll n)
// {
// 	bool prime[n + 1];
// 	memset(prime, true, sizeof(prime));

// 	for (ll p = 2; p * p <= n; p++)
// 	{
// 		if (prime[p] == true)
// 		{
// 			for (ll i = p * p; i <= n; i += p)
// 				prime[i] = false;
// 		}
// 	}
// 	for (ll p = 2; p <= n; p++)
// 		if (prime[p])
// 			isPrime[p] = 1;;
// }
// ll binaryToDecimal(vi& num)
// {
// 	//string num = n;
// 	ll dec_value = 0;

// 	// Initializing base value to 1, i.e 2^0
// 	ll base = 1;

// 	ll len = num.size();
// 	for (ll i = 0; i < len; i++) {
// 		if (num[i] == 1)
// 			dec_value += base;
// 		base = base * 2;
// 	}

// 	return dec_value;
// }

ll power_mod(ll x, ll y, ll p)
{
	ll res = 1;     // Initialize result

	x = x % p; // Update x if it is more than or
	// equal to p

	if (x == 0) return 0; // In case x is divisible by p;

	while (y > 0)
	{
		// If y is odd, multiply x with result
		if (y & 1)
			res = (res * x) % p;

		// y must be even now
		y = y >> 1; // y = y/2
		x = (x * x) % p;
	}
	return res;
}

ll power(ll x, ll y) {
	ll res = 1;
	while (y) {
		if (y % 2 == 1) {
			res *= x;
			y--;
		}
		else {
			x *= (x);
			y /= 2;
		}
	}
	return res;
}

// ll sq(ll n) {
// 	return (n * n);
// }

// ll gcdExtended(ll a, ll b, ll *x, ll *y);

// // Function to find modulo inverse of a
// ll modInverse(ll a, ll m)
// {
// 	ll x, y;
// 	ll g = gcdExtended(a, m, &x, &y);
// 	ll res = (x % m + m) % m;
// 	return res;

// }

// ll gcdExtended(ll a, ll b, ll *x, ll *y)
// {
// 	// Base Case
// 	if (a == 0)
// 	{
// 		*x = 0, *y = 1;
// 		return b;
// 	}

// 	ll x1, y1; // To store results of recursive call
// 	ll gcd = gcdExtended(b % a, a, &x1, &y1);

// 	// Update x and y using results of recursive
// 	// call
// 	*x = y1 - (b / a) * x1;
// 	*y = x1;

// 	return gcd;
// }

void primeFactors(ll n, umii& mp)
{
	unordered_map<ll, bool> lop;
	while (n % 2 == 0)
	{
		lop[2] = 1;
		n = n / 2;
	}
	for (ll i = 3; i <= sqrt(n); i = i + 2)
	{
		while (n % i == 0)
		{
			lop[i] = 1;
			n = n / i;
		}
	}
	if (n > 2)
		lop[n] = 1;
	for (auto it : lop) {
		if (it.ss) {
			mp[it.ff]++;
		}
	}
}

// void decToBinary(ll n, vi& binaryNum)
// {
// 	ll i = 0;
// 	while (n > 0) {
// 		binaryNum[i] = n % 2;
// 		n = n / 2;
// 		i++;
// 	}
// }

// ll getAns(umii& a, umii& c) {
// 	umii kitne;
// 	for (auto it : c) {
// 		if (it.ss % 2 == 1) {
// 			return -1;
// 		}
// 		kitne[it.ff] = it.ss / 2;
// 	}
// 	vi aMeAyega;
// 	for (auto it : kitne) {
// 		ll diff = mod(it.ss - a[it.ff]);
// 		f(i, diff) {
// 			aMeAyega.pb(it.ff);
// 		}

// 	}
// 	ll ans = 0;
// 	sort(all(aMeAyega));

// 	f(i, aMeAyega.sz / 2) {
// 		ans += aMeAyega[i];
// 	}
// 	return ans;
// }
ll gcd(ll a, ll b) {
	return __gcd(a, b);
}

// ll factMod(ll n) {
// 	ll ans = 1;
// 	fa(i, 1, n + 1) {
// 		ans *= i;
// 		ans %= rem;
// 	}
// 	return ans;
// }

// string numToString(ll num){
// 	string ans = "";
// 	while(num){
// 		ll temp = num%10;
// 		ans+=to_string(temp%2);
// 		num/=2;
// 	}
// 	while(ans.sz!=18){
// 		ans+='0';
// 	}
// 	reverse(ans.begin(),ans.end());
// 	return ans;
// }

// void SieveOfEratosthenes(ll n, umii& mp)
// {
// 	// Create a boolean array "prime[0..n]" and initialize
// 	// all entries it as true. A value in prime[i] will
// 	// finally be false if i is Not a prime, else true.
// 	bool prime[n + 1];
// 	memset(prime, true, sizeof(prime));

// 	for (int p = 2; p * p <= n; p++)
// 	{
// 		// If prime[p] is not changed, then it is a prime
// 		if (prime[p] == true)
// 		{
// 			// Update all multiples of p greater than or
// 			// equal to the square of it
// 			// numbers which are multiple of p and are
// 			// less than p^2 are already been marked.
// 			for (int i = p * p; i <= n; i += p)
// 				prime[i] = false;
// 		}
// 	}

// 	// Print all prime numbers
// 	for (int p = 2; p <= n; p++)
// 		if (prime[p])
// 			mp[p]++;
// }

// void printDivisors(ll n, umii& mp)
// {
// 	// Note that this loop runs till square root
// 	for (ll i = 1; i <= sqrt(n); i++)
// 	{
// 		if (n % i == 0)
// 		{
// 			// If divisors are equal, print only one
// 			if (n / i == i) {
// 				mp[i]++;
// 			}

// 			else // Otherwise print both
// 				mp[i]++, mp[n / i]++;
// 		}
// 	}
// }

bool dfs(ll src, unordered_map<ll, vi>& adjList, vector<bool>& visited, ll level, vi& set1, vi& set2, vi& parent, vector<ll>& valueForVertex, ll value) {
	visited[src] = true;
	valueForVertex[src] = value;
	if (level % 2 == 0) {
		set1.pb(src);
	}
	else {
		set2.pb(src);
	}
	bool ans = true;
	for (ll j : adjList[src]) {
		if (visited[j] && j != parent[src]) {
			if ((value - valueForVertex[j]) % 2 == 0)
				return false;
		}
		else if (!visited[j]) {
			parent[j] = src;
			ans &= dfs(j, adjList, visited, level + 1, set1, set2, parent, valueForVertex, value + 1);
		}
	}
	return ans;
}

int main() {
	fast
	ll n, m;
	cin >> n >> m;
	unordered_map<ll, vi> adjList;
	f(i, m) {
		ll u, v;
		cin >> u >> v;
		adjList[u].pb(v);
		adjList[v].pb(u);
	}
	std::vector<bool> visited(n + 1, false);
	vi parent(n + 1);
	f(i, n + 1) parent[i] = i;
	vector<ll> set1;
	vector<ll> set2;
	vector<ll> valueForVertex(n + 1, -1);
	bool ans = dfs(1, adjList, visited, 0, set1, set2, parent, valueForVertex, 0);
	if (!ans)
		cout << -1 << endl;
	else {
		sort(all(set1));
		sort(all(set2));
		cout << set1.sz << endl;
		f(i, set1.sz) {
			cout << set1[i] << " ";
		}
		cout << endl;
		cout << set2.sz << endl;
		f(i, set2.sz) {
			cout << set2[i] << " ";
		}
		cout << endl;
	}
	return 0;
}