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

int N, K;
vector<int> u, v;

int main()
{
    int n, m;
    cin >> n >> m;
    int a[n], b[m];
    map<int, int> mp;
    map<int, int> mpp;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        mp[a[i]]++;
        mpp[a[i]]++;
        u.push_back(a[i]);
    }
    for (int i = 0; i < m; i++)
    {
        cin >> b[i];
        if (mp[b[i]] == 1)
            v.push_back(b[i]);
        if (mpp[b[i]] == 0)
            u.push_back(b[i]);
    }
    cout << v.size() << " " << u.size() << endl;
    sort(u.begin(), u.end());
    sort(v.begin(), v.end());
    for (int i = 0; i < v.size(); i++)
    {
        cout << v[i] << endl;
    }
    for (int i = 0; i < u.size(); i++)
    {
        cout << u[i] << endl;
    }
    return 0;
}

