/*  ---------------  Copyrighted With  -----------------

   -----   ----   -------   |      |   ------   ------     -----    -----  |     /
  |         |     |     |   |      |  |         |     |   |        |       |   /
  |         |     |------   |------|   -----    |-----     -----   |         /\
  |         |     |         |      |  |         |  \      |        |       |   \
   -----   ----   |         |      |   ------   |    \     ------   ----   |     \

    High Ratings for everyone......

*/

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

/* ----------------------------- START of Template ---------------*/
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop") // to pop argument of function as soon as it returns
#define ll long long
#define pb push_back
#define fs first
#define se second
#define rd(x) scanf("%lld", &x)
#define all(v) v.begin(),v.end()
#define pr(i, j) pair< i , j >
#define mp(i, j) map< i , j >
#define rep(i, a, b) for(ll i=a; i<b; ++i)
#define repe(i, a, b) for(ll i=a; i<=b; ++i)
#define jrep(i, a, b, c) for(ll i=a; i<b; i+=c)
#define jrepe(i, a, b, c) for(ll i=a;i<=b; i+=c)
#define inp(i, n, a) for(ll i=0;i<n;i++) cin>>a[i];
ll dx[4]={-1, 0, 0, +1};
ll dy[4]={0, -1, +1, 0};
const ll LINF = 1e18;
const ll INF = 1e9;
const ll MOD = 1e9+7;

ll strtoll(string s) { stringstream str(s); ll number=0; str>>number; return number; }

string lltostr(ll n){ stringstream ss; ss<<n; return ss.str(); }

ll llsqrt(ll x){ if(x==0 || x==1) return x; ll start=1, end=x/2, ans; while(start<=end) { ll mid=(start+end)/2; if(mid*mid==x) return mid;
        else if(mid <= x/mid) ans=mid,start=mid+1; else end=mid-1; }  return ans; }

vector<ll> spf;
void sieve(ll size) { spf.resize(size+1); for(ll i=1;i<=size; ++i) spf[i]=i; for(ll i=4;i<=size; i+=2) spf[i]=2;
    for(ll i=3;i*i<=size; ++i) { if(spf[i]==i) { for(ll j=i*i; j<=size; j+=i) if(spf[j]==j) spf[j]=i; } } }

ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m); t=(t*t)%m; if(b&1)t=(t*a)%m; return t;}

ll modInverse(ll a, ll m) { return power(a, m-2, m); }

void fastscan(ll &number){ bool negative = false; register ll c; number = 0; c = getchar(); if (c=='-') { negative = true; c = getchar(); }
    for (; (c>47 && c<58); c=getchar()) number = number *10 + c - 48; if (negative)  number *= -1;   }

/* ----------------------          End Of Template --------------------------------*/

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);
   // clock_t tStart = clock();

  /*---------------------------------------------------------------------------------------------------*/

    ll n, m;
    cin>>n>>m;
    vector<ll> v(n);
    for(ll i=0;i<n;i++) cin>>v[i];
    vector<ll> free;
    ll ans=0;
    vector<ll> arr[m];
    for(ll i=0;i<n;i++)
    {
        arr[v[i]%m].pb(i);
    }
    ll t=n/m;
    for(ll idx=0;idx<2*m;idx++)
    {
        ll i=idx%m;
        // if(n==200000 && m==2)    cout<<i<<endl;
        if(arr[i].size()>t)
        {
            for(ll p=arr[i].size()-1;arr[i].size()!=t;p--)
            {
                free.pb(arr[i][p]);
                arr[i].pop_back();
            }
        }
        else
        {
            ll j=free.size()-1;
            if(n=200000 && m==2) cout<<free.size()<<endl;
            for(; j>=0 && arr[i].size()<t; j--)
            {
                if(n==200000 && m==2) cout<<j<<endl;
                arr[i].pb(free[j]);
                // cout<<free[j]<<" ";
                ans+=((i-v[free[j]]%m)%m + m)%m;
                free.pop_back();
            }
        }
        // cout<<arr[i].size()<<endl;
    }
    cout<<ans<<endl;
    for(ll i=0;i<m;i++)
    {
        for(ll j=0;j<t;j++)
        {
            ll idx=arr[i][j];
            if(v[idx]%m>i)
            {
                v[idx]+=(m-(v[idx]%m-i));
            }
            else
            {
                v[idx]+=(i-v[idx]%m);
            }
        }
    }
    for(ll i=0;i<n;i++) cout<<v[i]<<" ";
  /*---------------------------------------------------------------------------------------------------*/

   // printf("Time taken: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
    return 0;
}


/*  ---------------  Copyrighted With  -----------------

   -----   ----   -------   |      |   ------   ------     -----    -----  |     /
  |         |     |     |   |      |  |         |     |   |        |       |   /
  |         |     |------   |------|   -----    |-----     -----   |         /\
  |         |     |         |      |  |         |  \      |        |       |   \
   -----   ----   |         |      |   ------   |    \     ------   ----   |     \

    High Ratings for everyone......

*/

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

/* ----------------------------- START of Template ---------------*/
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop") // to pop argument of function as soon as it returns
#define ll long long
#define pb push_back
#define fs first
#define se second
#define rd(x) scanf("%lld", &x)
#define all(v) v.begin(),v.end()
#define pr(i, j) pair< i , j >
#define mp(i, j) map< i , j >
#define rep(i, a, b) for(ll i=a; i<b; ++i)
#define repe(i, a, b) for(ll i=a; i<=b; ++i)
#define jrep(i, a, b, c) for(ll i=a; i<b; i+=c)
#define jrepe(i, a, b, c) for(ll i=a;i<=b; i+=c)
#define inp(i, n, a) for(ll i=0;i<n;i++) cin>>a[i];
ll dx[4]={-1, 0, 0, +1};
ll dy[4]={0, -1, +1, 0};
const ll LINF = 1e18;
const ll INF = 1e9;
const ll MOD = 1e9+7;

ll strtoll(string s) { stringstream str(s); ll number=0; str>>number; return number; }

string lltostr(ll n){ stringstream ss; ss<<n; return ss.str(); }

ll llsqrt(ll x){ if(x==0 || x==1) return x; ll start=1, end=x/2, ans; while(start<=end) { ll mid=(start+end)/2; if(mid*mid==x) return mid;
        else if(mid <= x/mid) ans=mid,start=mid+1; else end=mid-1; }  return ans; }

vector<ll> spf;
void sieve(ll size) { spf.resize(size+1); for(ll i=1;i<=size; ++i) spf[i]=i; for(ll i=4;i<=size; i+=2) spf[i]=2;
    for(ll i=3;i*i<=size; ++i) { if(spf[i]==i) { for(ll j=i*i; j<=size; j+=i) if(spf[j]==j) spf[j]=i; } } }

ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m); t=(t*t)%m; if(b&1)t=(t*a)%m; return t;}

ll modInverse(ll a, ll m) { return power(a, m-2, m); }

void fastscan(ll &number){ bool negative = false; register ll c; number = 0; c = getchar(); if (c=='-') { negative = true; c = getchar(); }
    for (; (c>47 && c<58); c=getchar()) number = number *10 + c - 48; if (negative)  number *= -1;   }

/* ----------------------          End Of Template --------------------------------*/

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);
   // clock_t tStart = clock();

  /*---------------------------------------------------------------------------------------------------*/

    ll n, m;
    cin>>n>>m;
    vector<ll> v(n);
    for(ll i=0;i<n;i++) cin>>v[i];
    vector<ll> free;
    ll ans=0;
    vector<ll> arr[m];
    for(ll i=0;i<n;i++)
    {
        arr[v[i]%m].pb(i);
    }
    ll t=n/m;
    for(ll idx=0;idx<2*m;idx++)
    {
        ll i=idx%m;
        // if(n==200000 && m==2)    cout<<i<<endl;
        if(arr[i].size()>t)
        {
            for(ll p=arr[i].size()-1;arr[i].size()!=t;p--)
            {
                free.pb(arr[i][p]);
                arr[i].pop_back();
            }
        }
        else
        {

            ll j=free.size()-1;
            if(m==2 && n==200000) cout<<j<<endl<<free.size()<<endl;
            for(; j>=0 && arr[i].size()<t; j--)
            {
                if(m==2 && n==200000) cout<<j<<endl;
                arr[i].pb(free[j]);
                // cout<<free[j]<<" ";
                ans+=((i-v[free[j]]%m)%m + m)%m;
                free.pop_back();
            }
        }
        // cout<<arr[i].size()<<endl;
    }
    cout<<ans<<endl;
    for(ll i=0;i<m;i++)
    {
        for(ll j=0;j<t;j++)
        {
            ll idx=arr[i][j];
            if(v[idx]%m>i)
            {
                v[idx]+=(m-(v[idx]%m-i));
            }
            else
            {
                v[idx]+=(i-v[idx]%m);
            }
        }
    }
    for(ll i=0;i<n;i++) cout<<v[i]<<" ";
  /*---------------------------------------------------------------------------------------------------*/

   // printf("Time taken: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
    return 0;
}


/*  ---------------  Copyrighted With  -----------------

   -----   ----   -------   |      |   ------   ------     -----    -----  |     /
  |         |     |     |   |      |  |         |     |   |        |       |   /
  |         |     |------   |------|   -----    |-----     -----   |         /\
  |         |     |         |      |  |         |  \      |        |       |   \
   -----   ----   |         |      |   ------   |    \     ------   ----   |     \

    High Ratings for everyone......

*/

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

/* ----------------------------- START of Template ---------------*/
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop") // to pop argument of function as soon as it returns
#define ll long long
#define pb push_back
#define fs first
#define se second
#define rd(x) scanf("%lld", &x)
#define all(v) v.begin(),v.end()
#define pr(i, j) pair< i , j >
#define mp(i, j) map< i , j >
#define rep(i, a, b) for(ll i=a; i<b; ++i)
#define repe(i, a, b) for(ll i=a; i<=b; ++i)
#define jrep(i, a, b, c) for(ll i=a; i<b; i+=c)
#define jrepe(i, a, b, c) for(ll i=a;i<=b; i+=c)
#define inp(i, n, a) for(ll i=0;i<n;i++) cin>>a[i];
ll dx[4]={-1, 0, 0, +1};
ll dy[4]={0, -1, +1, 0};
const ll LINF = 1e18;
const ll INF = 1e9;
const ll MOD = 1e9+7;

ll strtoll(string s) { stringstream str(s); ll number=0; str>>number; return number; }

string lltostr(ll n){ stringstream ss; ss<<n; return ss.str(); }

ll llsqrt(ll x){ if(x==0 || x==1) return x; ll start=1, end=x/2, ans; while(start<=end) { ll mid=(start+end)/2; if(mid*mid==x) return mid;
        else if(mid <= x/mid) ans=mid,start=mid+1; else end=mid-1; }  return ans; }

vector<ll> spf;
void sieve(ll size) { spf.resize(size+1); for(ll i=1;i<=size; ++i) spf[i]=i; for(ll i=4;i<=size; i+=2) spf[i]=2;
    for(ll i=3;i*i<=size; ++i) { if(spf[i]==i) { for(ll j=i*i; j<=size; j+=i) if(spf[j]==j) spf[j]=i; } } }

ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m); t=(t*t)%m; if(b&1)t=(t*a)%m; return t;}

ll modInverse(ll a, ll m) { return power(a, m-2, m); }

void fastscan(ll &number){ bool negative = false; register ll c; number = 0; c = getchar(); if (c=='-') { negative = true; c = getchar(); }
    for (; (c>47 && c<58); c=getchar()) number = number *10 + c - 48; if (negative)  number *= -1;   }

/* ----------------------          End Of Template --------------------------------*/

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);
   // clock_t tStart = clock();

  /*---------------------------------------------------------------------------------------------------*/

    ll n, m;
    cin>>n>>m;
    vector<ll> v(n);
    for(ll i=0;i<n;i++) cin>>v[i];
    vector<ll> free;
    ll ans=0;
    vector<ll> arr[m];
    for(ll i=0;i<n;i++)
    {
        arr[v[i]%m].pb(i);
    }
    ll t=n/m;
    for(ll idx=0;idx<2*m;idx++)
    {
        ll i=idx%m;
        // if(n==200000 && m==2)    cout<<i<<endl;
        if(arr[i].size()>t)
        {
            for(ll p=arr[i].size()-1;arr[i].size()!=t;p--)
            {
                free.pb(arr[i][p]);
                arr[i].pop_back();
            }
        }
        else
        {

            ll j=free.size()-1;
            if(m==2 && n==200000) cout<<j<endl<<free.size()<<endl;
            for(; j>=0 && arr[i].size()<t; j--)
            {
                if(m==2 && n==200000) cout<<j<<endl;
                arr[i].pb(free[j]);
                // cout<<free[j]<<" ";
                ans+=((i-v[free[j]]%m)%m + m)%m;
                free.pop_back();
            }
        }
        // cout<<arr[i].size()<<endl;
    }
    cout<<ans<<endl;
    for(ll i=0;i<m;i++)
    {
        for(ll j=0;j<t;j++)
        {
            ll idx=arr[i][j];
            if(v[idx]%m>i)
            {
                v[idx]+=(m-(v[idx]%m-i));
            }
            else
            {
                v[idx]+=(i-v[idx]%m);
            }
        }
    }
    for(ll i=0;i<n;i++) cout<<v[i]<<" ";
  /*---------------------------------------------------------------------------------------------------*/

   // printf("Time taken: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
    return 0;
}


/*  ---------------  Copyrighted With  -----------------

   -----   ----   -------   |      |   ------   ------     -----    -----  |     /
  |         |     |     |   |      |  |         |     |   |        |       |   /
  |         |     |------   |------|   -----    |-----     -----   |         /\
  |         |     |         |      |  |         |  \      |        |       |   \
   -----   ----   |         |      |   ------   |    \     ------   ----   |     \

    Codeforces Contest 992 (Div 2)....
    High Ratings for everyone......

*/

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

/* ----------------------------- START of Template ---------------*/
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop") // to pop argument of function as soon as it returns
#define ll long long
#define pb push_back
#define fs first
#define se second
#define rd(x) scanf("%lld", &x)
#define all(v) v.begin(),v.end()
#define pr(i, j) pair< i , j >
#define mp(i, j) map< i , j >
#define rep(i, a, b) for(ll i=a; i<b; ++i)
#define repe(i, a, b) for(ll i=a; i<=b; ++i)
#define jrep(i, a, b, c) for(ll i=a; i<b; i+=c)
#define jrepe(i, a, b, c) for(ll i=a;i<=b; i+=c)
#define inp(i, n, a) for(ll i=0;i<n;i++) cin>>a[i];
ll dx[4]={-1, 0, 0, +1};
ll dy[4]={0, -1, +1, 0};
const ll LINF = 1e18;
const ll INF = 1e9;
const ll MOD = 1e9+7;

ll strtoll(string s) { stringstream str(s); ll number=0; str>>number; return number; }

string lltostr(ll n){ stringstream ss; ss<<n; return ss.str(); }

ll llsqrt(ll x){ if(x==0 || x==1) return x; ll start=1, end=x/2, ans; while(start<=end) { ll mid=(start+end)/2; if(mid*mid==x) return mid;
        else if(mid <= x/mid) ans=mid,start=mid+1; else end=mid-1; }  return ans; }

vector<ll> spf;
void sieve(ll size) { spf.resize(size+1); for(ll i=1;i<=size; ++i) spf[i]=i; for(ll i=4;i<=size; i+=2) spf[i]=2;
    for(ll i=3;i*i<=size; ++i) { if(spf[i]==i) { for(ll j=i*i; j<=size; j+=i) if(spf[j]==j) spf[j]=i; } } }

ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m); t=(t*t)%m; if(b&1)t=(t*a)%m; return t;}

ll modInverse(ll a, ll m) { return power(a, m-2, m); }

void fastscan(ll &number){ bool negative = false; register ll c; number = 0; c = getchar(); if (c=='-') { negative = true; c = getchar(); }
    for (; (c>47 && c<58); c=getchar()) number = number *10 + c - 48; if (negative)  number *= -1;   }

/* ----------------------          End Of Template --------------------------------*/

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);
   // clock_t tStart = clock();

  /*---------------------------------------------------------------------------------------------------*/

    ll n, m;
    cin>>n>>m;
    vector<ll> v(n, 0);
    for(ll i=0;i<n;i++) cin>>v[i];
    vector<ll> c(m, 0);
    for(ll i=0;i<n;i++)
    {
        c[v[i]%m]++;
    }
    set<ll> s;
    vector<pair<ll,ll> > l;
    for(ll i=0;i<m;i++)
    {
        if(c[i]<n/m) s.insert(i), s.insert(i+m);
        else if(c[i]>n/m) l.pb({c[i], i});
    }
    sort(all(l));
    ll ans=0;
    vector<pair<ll,ll> > ch[m+5];
    for(ll i=l.size()-1;i>=0;i--)
    {
        ll idx=l[i].se;
        if(c[idx]==n/m) continue;
        auto it=lower_bound(s.begin(), s.end(), idx);
        ll j=*it;
        ll g=min(n/m-c[j%m], c[idx]-n/m);
        c[j%m]+=g;
        c[idx]-=g;
        ans+=g*(j-idx);
        if(c[j%m]==n/m)
        {
            if(s.find(j%m)!=s.end()) s.erase(s.find(j%m));
            if(s.find(j%m+m)!=s.end()) s.erase(s.find(j%m+m));
        }
        ch[idx].pb({j%m, g});
        if(c[idx]==n/m) continue;
        else i++;
    }
    cout<<ans<<endl;
    vector<ll> co(m, n/m);
    for(ll i=0;i<v.size();i++)
    {
        ll idx=v[i]%m;
        if(co[idx]>0) cout<<v[i]<<" ", co[idx]--;
        else
        {
            ll j=ch[idx][ch[idx].size()-1].fs;
            cout<<v[i] + abs(j-idx)<<" ";
            ch[idx][ch[idx].size()-1].se--;
            if(ch[idx][ch[idx].size()-1].se==0) ch[idx].pop_back();
        }
    }

  /*---------------------------------------------------------------------------------------------------*/

   // printf("Time taken: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=2e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

ll d[MAXn];
vector<ll> stk;
vector<ll> idx[MAXn];
int main(){
  IOS();
  ll n,m;
  cin >> n >> m;
  REP (i,n) {
    cin >> d[i];
    idx[d[i]%m].eb(i);
  }

  ll tg = n/m;
  REP (i,m) {
    if (SZ(idx[i]) > tg) stk.eb(i);
  }
  ll ans = 0;
  REP (i,m) {
    if (!SZ(stk)) break;
    if (SZ(idx[i]) < tg) {
      ll tmp = tg-SZ(idx[i]);
      debug(tmp);
      REP (j,tmp) {
        if (SZ(idx[stk.back()]) == tg) stk.pob();
        d[idx[stk.back()].back()] += (i-stk.back()+m)%m;
        idx[i].eb(idx[stk.back()].back());
        idx[stk.back()].pob();
        ans += (i-stk.back()+m)%m;
      }
    }
    else if (SZ(idx[i]) > tg) stk.eb(i);
  }
  cout << ans << endl;
  REP (i,n) cout << d[i] << " \n"[i==n-1];
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=2e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

ll d[MAXn],dt[MAXn];
ll cnt[MAXn];
vector<ll> idx[MAXn];
int main(){
  IOS();
  ll n,m;
  cin >> n >> m;
  REP (i,n) {
    cin >> d[i];
    // cnt[d[i]%m]++;
    idx[d[i]%m].eb(i);
  }

  ll tg = n/m;
  priority_queue<ii> pq;
  REP (i,m) pq.push({SZ(idx[i]),i});
  ll ans = 0;
  REP (i,m) {
    ii cur = pq.top();
    if (cur.X == tg) break;
    pq.pop();
    debug(cur);
    ll tmp = cur.X-tg;
    ll nxt = cur.Y+1;
    if (nxt == m) nxt = 0;
    ans += tmp;
    REP (j,tmp) {
      dt[idx[cur.Y].back()]++;
      idx[nxt].eb(idx[cur.Y].back());
      idx[cur.Y].pob();
    }
    pq.push({SZ(idx[nxt]),nxt});
  }
  pary(dt,dt+m);
  cout << ans << endl;
  REP (i,n) cout << d[i] + dt[i] << " \n"[i==n-1];
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=2e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

ll d[MAXn];
vector<ll> stk;
vector<ll> idx[MAXn];
int main(){
  IOS();
  ll n,m;
  cin >> n >> m;
  REP (i,n) {
    cin >> d[i];
    idx[d[i]%m].eb(i);
  }

  ll tg = n/m;
  REP (i,m) {
    if (SZ(idx[i]) > tg) stk.eb(i);
  }
  ll ans = 0;
  REP (i,m) {
    if (!SZ(stk)) break;
    if (SZ(idx[i]) < tg) {
      ll tmp = tg-SZ(idx[i]);
      debug(tmp);
      REP (j,tmp) {
        if (SZ(idx[stk.back()]) == tg) stk.pob();
        if (!SZ(stk)) break;
        d[idx[stk.back()].back()] += (i-stk.back()+m)%m;
        idx[i].eb(idx[stk.back()].back());
        idx[stk.back()].pob();
        ans += (i-stk.back()+m)%m;
      }
    }
    else if (SZ(idx[i]) > tg) stk.eb(i);
  }
  cout << ans << endl;
  REP (i,n) cout << d[i] << " \n"[i==n-1];
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=2e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

ll d[MAXn],dt[MAXn];
ll cnt[MAXn];
vector<ll> idx[MAXn];
int main(){
  IOS();
  ll n,m;
  cin >> n >> m;
  REP (i,n) {
    cin >> d[i];
    cnt[d[i]%m]++;
    idx[d[i]%m].eb(i);
  }

  pary(cnt,cnt+m);
  pary(idx,idx+m);
  ll tg = n/m;
  set<ii,greater<ii> > st;
  REP (i,m) st.insert({cnt[i],i});
  ll ans = 0;
  REP (i,m) {
    debug(SZ(st));
    ii cur = *st.begin();
    if (cur.X == tg) break;
    st.erase(st.begin());
    st.erase({tg,cur.Y});
    debug(cur);
    ll tmp = cur.X-tg;
    ll nxt = cur.Y+1;
    if (nxt == m) nxt = 0;
    st.erase({cnt[nxt],nxt});
    ans += tmp;
    REP (j,tmp) {
      dt[idx[cur.Y].back()]++;
      idx[nxt].eb(idx[cur.Y].back());
      idx[cur.Y].pob();
      cnt[nxt]++,cnt[cur.Y]--;
    }
    st.insert({cnt[nxt],nxt});
  }
  cout << ans << endl;
  REP (i,n) cout << d[i] + dt[i] << " \n"[i==n-1];
}


import java.util.*;
import java.io.*;
public class a
{
	public static void main(String[] arg) throws IOException
	{
		new a();
	}
	public a() throws IOException
	{
		FastScanner in = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int n = in.nextInt();
		int m = in.nextInt();
		int a = in.nextInt();
		int b = in.nextInt();
		int c = in.nextInt();
		int d = in.nextInt();
		if(m < n-1 + n-4)
		{
			out.println("-1");
		}
		else
		{
			ArrayList<Integer> path1 = new ArrayList<Integer>();
			path1.add(a);
			path1.add(c);
			for(int i = 1; i <= n; i++)
			{
				if(i == a || i == b || i == c || i == d) continue;
				path1.add(i);
			}
			path1.add(d);
			path1.add(b);

			ArrayList<Integer> path2 = new ArrayList<Integer>();
			for(int i = 1; i < path1.size()-3; i++)
			{
				path2.add(path1.get(i));
			}
			path2.add(a); path2.add(path1.get(path1.size()-3)); path2.add(b); path2.add(d);
			for(int v : path1) out.print(v + " ");
			out.println();
			for(int v : path2) out.print(v + " ");
			out.println();
		}
		in.close(); out.close();
	}

	class FastScanner
	{
		BufferedReader br;
		StringTokenizer st;
		public FastScanner(InputStream in)
		{
			br = new BufferedReader(new InputStreamReader(in));
			st = new StringTokenizer("");
		}
		public String next() throws IOException
		{
			while(!st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int nextInt() throws IOException
		{
			return Integer.parseInt(next());
		}
		void close() throws IOException
		{
			br.close();
		}
	}
}


import java.util.*;
import java.io.*;
public class a
{
	public static void main(String[] arg) throws IOException
	{
		new a();
	}
	public a() throws IOException
	{
		FastScanner in = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int n = in.nextInt();
		int m = in.nextInt();
		int a = in.nextInt();
		int b = in.nextInt();
		int c = in.nextInt();
		int d = in.nextInt();
		if(m < n-1 + 3)
		{
			out.println("-1");
		}
		else
		{
			ArrayList<Integer> path1 = new ArrayList<Integer>();
			path1.add(a);
			path1.add(c);
			for(int i = 1; i <= n; i++)
			{
				if(i == a || i == b || i == c || i == d) continue;
				path1.add(i);
			}
			path1.add(d);
			path1.add(b);

			ArrayList<Integer> path2 = new ArrayList<Integer>();
			for(int i = 1; i < path1.size()-3; i++)
			{
				path2.add(path1.get(i));
			}
			path2.add(a); path2.add(path1.get(path1.size()-3)); path2.add(b); path2.add(d);
			for(int v : path1) out.print(v + " ");
			out.println();
			for(int v : path2) out.print(v + " ");
			out.println();
		}
		in.close(); out.close();
	}

	class FastScanner
	{
		BufferedReader br;
		StringTokenizer st;
		public FastScanner(InputStream in)
		{
			br = new BufferedReader(new InputStreamReader(in));
			st = new StringTokenizer("");
		}
		public String next() throws IOException
		{
			while(!st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int nextInt() throws IOException
		{
			return Integer.parseInt(next());
		}
		void close() throws IOException
		{
			br.close();
		}
	}
}


import java.util.*;
import java.io.*;
public class a
{
	public static void main(String[] arg) throws IOException
	{
		new a();
	}
	public a() throws IOException
	{
		FastScanner in = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int n = in.nextInt();
		int m = in.nextInt();
		int a = in.nextInt();
		int b = in.nextInt();
		int c = in.nextInt();
		int d = in.nextInt();
		if(m < n-1 + 3 || n == 4)
		{
			out.println("-1");
		}
		else
		{
			ArrayList<Integer> path1 = new ArrayList<Integer>();
			path1.add(a);
			path1.add(c);
			for(int i = 1; i <= n; i++)
			{
				if(i == a || i == b || i == c || i == d) continue;
				path1.add(i);
			}
			path1.add(d);
			path1.add(b);

			ArrayList<Integer> path2 = new ArrayList<Integer>();
			for(int i = 1; i < path1.size()-3; i++)
			{
				path2.add(path1.get(i));
			}
			path2.add(a); path2.add(path1.get(path1.size()-3)); path2.add(b); path2.add(d);
			for(int v : path1) out.print(v + " ");
			out.println();
			for(int v : path2) out.print(v + " ");
			out.println();
		}
		in.close(); out.close();
	}

	class FastScanner
	{
		BufferedReader br;
		StringTokenizer st;
		public FastScanner(InputStream in)
		{
			br = new BufferedReader(new InputStreamReader(in));
			st = new StringTokenizer("");
		}
		public String next() throws IOException
		{
			while(!st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int nextInt() throws IOException
		{
			return Integer.parseInt(next());
		}
		void close() throws IOException
		{
			br.close();
		}
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

/**
 * @author Don Li
 */
public class BearTwoPaths {
    void solve() {
        int n = in.nextInt(), k = in.nextInt();
        int a = in.nextInt(), b = in.nextInt(), c = in.nextInt(), d = in.nextInt();

        if (n == 4 || k < n + 1) {
            out.println(-1);
            return;
        }

        boolean[] used = new boolean[n + 1];
        used[a] = used[b] = used[c] = used[d] = true;

        List<Integer> list = new ArrayList<>(n - 4);
        for (int i = 1; i <= n; i++) if (!used[i]) list.add(i);

        for (int i = 0; i < n; i++) {
            if (i > 0) out.print(' ');
            if (i == 0) out.print(a);
            else if (i == 1) out.print(c);
            else if (i == n - 2) out.print(d);
            else if (i == n - 1) out.print(b);
            else out.print(list.get(i - 2));
        }
        out.println();

        for (int i = 0; i < n; i++) {
            if (i > 0) out.print(' ');
            if (i == 0) out.print(c);
            else if (i == 1) out.print(a);
            else if (i == n - 2) out.print(b);
            else if (i == n - 1) out.print(d);
            else out.print(list.get(i - 2));
        }
        out.println();
    }

    public static void main(String[] args) {
        in = new FastScanner(new BufferedReader(new InputStreamReader(System.in)));
        out = new PrintWriter(System.out);
        new BearTwoPaths().solve();
        out.close();
    }

    static FastScanner in;
    static PrintWriter out;

    static class FastScanner {
        BufferedReader in;
        StringTokenizer st;

        public FastScanner(BufferedReader in) {
            this.in = in;
        }

        public String nextToken() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(in.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextToken());
        }

        public long nextLong() {
            return Long.parseLong(nextToken());
        }

        public double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Arthur Gazizov  [2oo7] - Kazan FU
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        FastPrinter out = new FastPrinter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, FastScanner in, FastPrinter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            int a = in.nextInt();
            int b = in.nextInt();
            int c = in.nextInt();
            int d = in.nextInt();
            if (n <= 4 || k < (n + 1)) {
                out.print(-1);
                return;
            }
            out.prints(a);
            out.prints(c);
            for (int i = 1; i <= n; i++) {
                if (i != a && i != b && i != c && i != d) {
                    out.prints(i);
                }
            }
            out.prints(d);
            out.println(b);
            out.prints(c);
            out.prints(a);
            for (int i = 1; i <= n; i++) {
                if (i != a && i != b && i != c && i != d) {
                    out.prints(i);
                }
            }
            out.prints(b);
            out.println(d);
        }

    }

    static class FastPrinter extends PrintWriter {
        public FastPrinter(Writer writer) {
            super(writer);
        }

        public FastPrinter(OutputStream out) {
            super(out);
        }

        public FastPrinter prints(int value) {
            print(value);
            print(' ');
            return this;
        }

        public void close() {
            super.close();
        }

    }

    static class FastScanner extends BufferedReader {
        boolean isEOF;

        public FastScanner(InputStream is) {
            super(new InputStreamReader(is));
        }

        public FastScanner(InputStreamReader inputStreamReader) {
            super(inputStreamReader);
        }

        public int read() {
            try {
                int ret = super.read();
                if (isEOF && ret < 0) {
                    throw new InputMismatchException();
                }
                isEOF = ret == -1;
                return ret;
            } catch (IOException e) {
                throw new InputMismatchException();
            }
        }

        public static boolean isWhiteSpace(int c) {
            return c >= -1 && c <= 32;
        }

        public int nextInt() {
            int c = read();
            while (isWhiteSpace(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int ret = 0;
            while (!isWhiteSpace(c)) {
                if (c < '0' || c > '9') {
                    throw new NumberFormatException("digit expected " + (char) c
                            + " found");
                }
                ret = ret * 10 + c - '0';
                c = read();
            }
            return ret * sgn;
        }

        public String readLine() {
            try {
                return super.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return null;
        }

    }
}


import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Problem_04 {

    public static void main(String[] args) throws Exception {
        Scanner input = new Scanner();
        //BufferedWriter output = new BufferedWriter(new OutputStreamWriter(System.out));
        int n = input.nextInt();
        int k = input.nextInt();
        int a = input.nextInt();
        int b = input.nextInt();
        int c = input.nextInt();
        int d = input.nextInt();

        if (n == 4 || n + 1 > k) {
            System.out.println(-1);
            return;
        }

        System.out.printf("%d %d", a, c);
        for (int i = 1; i <=n; i++) {
            if (i != a && i!=b && i!=c && i!=d) {
                System.out.printf(" %d", i);
            }
        }
        System.out.printf(" %d %d\n", d, b);

        System.out.printf("%d %d", c, a);
        for (int i = 1; i <=n; i++) {
            if (i != a && i!=b && i!=c && i!=d) {
                System.out.printf(" %d", i);
            }
        }
        System.out.printf(" %d %d\n", b, d);
    }

    static class Scanner {
        final BufferedReader input;
        String[] buffer;
        int pos;

        public Scanner() {
            input = new BufferedReader(new InputStreamReader(System.in));
        }

        private String read() {
            try {
                if (buffer == null || pos >= buffer.length) {
                    buffer = input.readLine().split("\\s+");
                    pos = 0;
                }
                return buffer[pos++];
            } catch (Exception ex) {
                throw new RuntimeException(ex);
            }
        }

        long nextLong() {
            return Long.parseLong(read());
        }

        int nextInt() {
            return Integer.parseInt(read());
        }

        double nextDouble() {
            return Double.parseDouble(read());
        }

        String nextLine() {
            if (buffer != null && pos < buffer.length) {
                throw new RuntimeException("Buffer is not empty");
            }
            try {
                return input.readLine();
            } catch (Exception ex) {
                throw new RuntimeException(ex);
            }
        }
    }

}


/**
 *
 * @author sarthak
 */

import java.util.*;
import java.math.*;
import java.io.*;

public class rnd351_D {

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
                return "";
            }
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }
    }
static class P implements Comparable{

        private int x, y;

        public P(int x, int y) {
            this.x = x;
            this.y = y;
        }

        public int hashCode() {
            return (x * 31) ^ y;
        }

        public boolean equals(Object o) {
            if (o instanceof P) {
                P other = (P) o;
                return (x == other.x && y == other.y);
            }
            return false;
        }
        public int compareTo(Object obj) {
		P l = (P) obj;
		if (this.x == l.x){
			if (this.y == l.y) return 0;
			return (this.y < l.y)? -1: 1;
		}
		return (this.x < l.x)? -1: 1;
	}
    }

    public static void main(String[] args){

    FastScanner s = new FastScanner(System.in);
    StringBuilder op1=new StringBuilder();
    StringBuilder op2=new StringBuilder();

    int n=s.nextInt();
    int k=s.nextInt();
    int er=6+n-4-1;
    if(n<=4 || k<er)){
        System.out.println(-1);
        return;
    }
    int a=s.nextInt();
    int b=s.nextInt();
    int c=s.nextInt();
    int d=s.nextInt();
    op1.append(a+" "+ d+" ");
    ArrayList<Integer> al=new ArrayList<>();
    for(int i=1;i<=n;i++){
        if(i!=a&&i!=b&&i!=c&&i!=d)
            al.add(i);

    }
    for(int i:al)
        op1.append(i+" ");
    op1.append(c+" " + b);

    op2.append(c+" "+ b+" ");
    for(int i=al.size()-1;i>=0;i--)
        op2.append(al.get(i)+" ");
    op2.append(a+" " + d);
    System.out.println(op1);
    System.out.println(op2);

    }

}


/**
 *
 * @author sarthak
 */

import java.util.*;
import java.math.*;
import java.io.*;

public class rnd351_D {

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
                return "";
            }
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }
    }
static class P implements Comparable{

        private int x, y;

        public P(int x, int y) {
            this.x = x;
            this.y = y;
        }

        public int hashCode() {
            return (x * 31) ^ y;
        }

        public boolean equals(Object o) {
            if (o instanceof P) {
                P other = (P) o;
                return (x == other.x && y == other.y);
            }
            return false;
        }
        public int compareTo(Object obj) {
		P l = (P) obj;
		if (this.x == l.x){
			if (this.y == l.y) return 0;
			return (this.y < l.y)? -1: 1;
		}
		return (this.x < l.x)? -1: 1;
	}
    }

    public static void main(String[] args){

    FastScanner s = new FastScanner(System.in);
    StringBuilder op1=new StringBuilder();
    StringBuilder op2=new StringBuilder();

    int n=s.nextInt();
    int k=s.nextInt();
    int er=6+n-4-1;
    if(n<=4 || k<er){
        System.out.println(-1);
        return;
    }
    int a=s.nextInt();
    int b=s.nextInt();
    int c=s.nextInt();
    int d=s.nextInt();
    op1.append(a+" "+ d+" ");
    ArrayList<Integer> al=new ArrayList<>();
    for(int i=1;i<=n;i++){
        if(i!=a&&i!=b&&i!=c&&i!=d)
            al.add(i);

    }
    for(int i:al)
        op1.append(i+" ");
    op1.append(c+" " + b);

    op2.append(c+" "+ b+" ");
    for(int i=al.size()-1;i>=0;i--)
        op2.append(al.get(i)+" ");
    op2.append(a+" " + d);
    System.out.println(op1);
    System.out.println(op2);

    }

}


/**
 *
 * @author sarthak
 */

import java.util.*;
import java.math.*;
import java.io.*;

public class rnd351_D {

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
                return "";
            }
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }
    }
static class P implements Comparable{

        private int x, y;

        public P(int x, int y) {
            this.x = x;
            this.y = y;
        }

        public int hashCode() {
            return (x * 31) ^ y;
        }

        public boolean equals(Object o) {
            if (o instanceof P) {
                P other = (P) o;
                return (x == other.x && y == other.y);
            }
            return false;
        }
        public int compareTo(Object obj) {
		P l = (P) obj;
		if (this.x == l.x){
			if (this.y == l.y) return 0;
			return (this.y < l.y)? -1: 1;
		}
		return (this.x < l.x)? -1: 1;
	}
    }

    public static void main(String[] args){

    FastScanner s = new FastScanner(System.in);
    StringBuilder op1=new StringBuilder();
    StringBuilder op2=new StringBuilder();

    int n=s.nextInt();
    int k=s.nextInt();
    if(n<=4 || k<(n+3)){
        System.out.println(-1);
        return;
    }
    int a=s.nextInt();
    int b=s.nextInt();
    int c=s.nextInt();
    int d=s.nextInt();
    op1.append(a+" "+ d+" ");
    ArrayList<Integer> al=new ArrayList<>();
    for(int i=1;i<=n;i++){
        if(i!=a&&i!=b&&i!=c&&i!=d)
            al.add(i);

    }
    for(int i:al)
        op1.append(i+" ");
    op1.append(c+" " + b);

    op2.append(c+" "+ b+" ");
    for(int i=al.size()-1;i>=0;i--)
        op2.append(al.get(i)+" ");
    op2.append(a+" " + d);
    System.out.println(op1);
    System.out.println(op2);

    }

}


/**
 *
 * @author sarthak
 */

import java.util.*;
import java.math.*;
import java.io.*;

public class rnd351_D {

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
                return "";
            }
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }
    }
static class P implements Comparable{

        private int x, y;

        public P(int x, int y) {
            this.x = x;
            this.y = y;
        }

        public int hashCode() {
            return (x * 31) ^ y;
        }

        public boolean equals(Object o) {
            if (o instanceof P) {
                P other = (P) o;
                return (x == other.x && y == other.y);
            }
            return false;
        }
        public int compareTo(Object obj) {
		P l = (P) obj;
		if (this.x == l.x){
			if (this.y == l.y) return 0;
			return (this.y < l.y)? -1: 1;
		}
		return (this.x < l.x)? -1: 1;
	}
    }

    public static void main(String[] args){

    FastScanner s = new FastScanner(System.in);
    StringBuilder op1=new StringBuilder();
    StringBuilder op2=new StringBuilder();

    int n=s.nextInt();
    int k=s.nextInt();
    if(n<=4){
        System.out.println(-1);
        return;
    }
    int a=s.nextInt();
    int b=s.nextInt();
    int c=s.nextInt();
    int d=s.nextInt();
    op1.append(a+" "+ d+" ");
    ArrayList<Integer> al=new ArrayList<>();
    for(int i=1;i<=n;i++){
        if(i!=a&&i!=b&&i!=c&&i!=d)
            al.add(i);

    }
    for(int i:al)
        op1.append(i+" ");
    op1.append(c+" " + b);

    op2.append(c+" "+ b+" ");
    for(int i=al.size()-1;i>=0;i--)
        op2.append(al.get(i)+" ");
    op2.append(a+" " + d);
    System.out.println(op1);
    System.out.println(op2);

    }

}


import java.io.*;
import java.util.*;

public class D {

    void solve() throws IOException {
        in = new InputReader("__std");
        out = new OutputWriter("__std");

        int n = in.readInt();
        int k = in.readInt();
        int a = in.readInt();
        int b = in.readInt();
        int c = in.readInt();
        int d = in.readInt();
        if (n < 5 || k < n + 1) {
            out.println(-1);
        } else {
            int[] p = new int[n + 1];
            p[a] = p[b] = p[c] = p[d] = -1;
            int e = 1;
            while (p[e] == -1) ++e;
            int f = n;
            while (p[f] == -1) --f;
            p[e] = p[f] = -2;
            int u = f;
            for (int i = 0; i < n - 6; ++i) {
                int v = 1;
                while (p[v] != 0) ++v;
                p[v] = u;
                u = v;
            }
            if (u != e) p[e] = u;

            out.print(a + " " + c + " ");
            u = e;
            while (u > 0) {
                out.print(u + " ");
                u = p[u];
            }
            out.println(d + " " + b);

            out.print(c + " " + a + " ");
            u = e;
            while (u > 0) {
                out.print(u + " ");
                u = p[u];
            }
            out.println(b + " " + d);
        }

        exit();
    }

    void exit() {
        //System.err.println((System.currentTimeMillis() - startTime) + " ms");
        out.close();
        System.exit(0);
    }

    InputReader in;
    OutputWriter out;

    //long startTime = System.currentTimeMillis();

    public static void main(String[] args) throws IOException {
        new D().solve();
    }

    class InputReader {

        private InputStream stream;

        private byte[] buffer = new byte[1024];
        private int pos, len;

        private int cur;

        private StringBuilder sb = new StringBuilder(32);

        InputReader(String name) throws IOException {
            if (name.equals("__std")) {
                stream = System.in;
            } else {
                stream = new FileInputStream(name);
            }
            cur = read();
        }

        private int read() throws IOException {
            if (len == -1) {
                throw new EOFException();
            }
            if (pos >= len) {
                pos = 0;
                len = stream.read(buffer);
                if (len == -1) return -1;
            }
            return buffer[pos++];
        }

        private boolean whitespace() {
            return cur == ' ' || cur == '\t' || cur == '\r' || cur == '\n' || cur == -1;
        }

        char readChar() throws IOException {
            if (cur == -1) {
                throw new EOFException();
            }
            char res = (char) cur;
            cur = read();
            return res;
        }

        int readInt() throws IOException {
            if (cur == -1) {
                throw new EOFException();
            }
            while (whitespace()) {
                cur = read();
            }
            if (cur == -1) {
                throw new EOFException();
            }
            int sign = 1;
            if (cur == '-') {
                sign = -1;
                cur = read();
            }
            int res = 0;
            while (!whitespace()) {
                if (cur < '0' || cur > '9') {
                    throw new NumberFormatException();
                }
                res *= 10;
                res += cur - '0';
                cur = read();
            }
            return res * sign;
        }

        long readLong() throws IOException {
            if (cur == -1) {
                throw new EOFException();
            }
            return Long.parseLong(readToken());
        }

        double readDouble() throws IOException {
            if (cur == -1) {
                throw new EOFException();
            }
            return Double.parseDouble(readToken());
        }

        String readLine() throws IOException {
            if (cur == -1) {
                throw new EOFException();
            }
            sb.setLength(0);
            while (cur != -1 && cur != '\r' && cur != '\n') {
                sb.append((char) cur);
                cur = read();
            }
            if (cur == '\r') {
                cur = read();
            }
            if (cur == '\n') {
                cur = read();
            }
            return sb.toString();
        }

        String readToken() throws IOException {
            if (cur == -1) {
                throw new EOFException();
            }
            while (whitespace()) {
                cur = read();
            }
            if (cur == -1) {
                throw new EOFException();
            }
            sb.setLength(0);
            while (!whitespace()) {
                sb.append((char) cur);
                cur = read();
            }
            return sb.toString();
        }

        boolean eof() {
            return cur == -1;
        }
    }

    class OutputWriter {

        private PrintWriter writer;

        OutputWriter(String name) throws IOException {
            if (name.equals("__std")) {
                writer = new PrintWriter(System.out);
            } else {
                writer = new PrintWriter(name);
            }
        }

        void print(String format, Object ... args) {
            writer.print(new Formatter(Locale.US).format(format, args));
        }

        void println(String format, Object ... args) {
            writer.println(new Formatter(Locale.US).format(format, args));
        }

        void print(Object value) {
            writer.print(value);
        }

        void println(Object value) {
            writer.println(value);
        }

        void println() {
            writer.println();
        }

        void flush() {
            writer.flush();
        }

        void close() {
            writer.close();
        }
    }
}


import java.io.*;
import java.util.*;

public class D {

    void solve() throws IOException {
        in = new InputReader("__std");
        out = new OutputWriter("__std");

        int n = in.readInt();
        int k = in.readInt();
        int a = in.readInt();
        int b = in.readInt();
        int c = in.readInt();
        int d = in.readInt();
        if (k < n) {
            out.println(-1);
        } else {
            int[] p = new int[n + 1];
            p[a] = -1;
            p[c] = a;
            p[d] = c;
            out.print(a + " " + c + " " + d);
            int u = d;
            for (int i = 0; i < n - 4; ++i) {
                int v = 1;
                while (v == b || p[v] != 0) ++v;
                p[v] = u;
                u = v;
                out.print(" " + u);
            }
            p[b] = u;
            out.println(" " + b);
            out.print(c + " " + a + " " + b);
            u = b;
            for (int i = 0; i < n - 4; ++i) {
                u = p[u];
                out.print(" " + u);
            }
            out.println(" " + d);
        }

        exit();
    }

    void exit() {
        //System.err.println((System.currentTimeMillis() - startTime) + " ms");
        out.close();
        System.exit(0);
    }

    InputReader in;
    OutputWriter out;

    //long startTime = System.currentTimeMillis();

    public static void main(String[] args) throws IOException {
        new D().solve();
    }

    class InputReader {

        private InputStream stream;

        private byte[] buffer = new byte[1024];
        private int pos, len;

        private int cur;

        private StringBuilder sb = new StringBuilder(32);

        InputReader(String name) throws IOException {
            if (name.equals("__std")) {
                stream = System.in;
            } else {
                stream = new FileInputStream(name);
            }
            cur = read();
        }

        private int read() throws IOException {
            if (len == -1) {
                throw new EOFException();
            }
            if (pos >= len) {
                pos = 0;
                len = stream.read(buffer);
                if (len == -1) return -1;
            }
            return buffer[pos++];
        }

        private boolean whitespace() {
            return cur == ' ' || cur == '\t' || cur == '\r' || cur == '\n' || cur == -1;
        }

        char readChar() throws IOException {
            if (cur == -1) {
                throw new EOFException();
            }
            char res = (char) cur;
            cur = read();
            return res;
        }

        int readInt() throws IOException {
            if (cur == -1) {
                throw new EOFException();
            }
            while (whitespace()) {
                cur = read();
            }
            if (cur == -1) {
                throw new EOFException();
            }
            int sign = 1;
            if (cur == '-') {
                sign = -1;
                cur = read();
            }
            int res = 0;
            while (!whitespace()) {
                if (cur < '0' || cur > '9') {
                    throw new NumberFormatException();
                }
                res *= 10;
                res += cur - '0';
                cur = read();
            }
            return res * sign;
        }

        long readLong() throws IOException {
            if (cur == -1) {
                throw new EOFException();
            }
            return Long.parseLong(readToken());
        }

        double readDouble() throws IOException {
            if (cur == -1) {
                throw new EOFException();
            }
            return Double.parseDouble(readToken());
        }

        String readLine() throws IOException {
            if (cur == -1) {
                throw new EOFException();
            }
            sb.setLength(0);
            while (cur != -1 && cur != '\r' && cur != '\n') {
                sb.append((char) cur);
                cur = read();
            }
            if (cur == '\r') {
                cur = read();
            }
            if (cur == '\n') {
                cur = read();
            }
            return sb.toString();
        }

        String readToken() throws IOException {
            if (cur == -1) {
                throw new EOFException();
            }
            while (whitespace()) {
                cur = read();
            }
            if (cur == -1) {
                throw new EOFException();
            }
            sb.setLength(0);
            while (!whitespace()) {
                sb.append((char) cur);
                cur = read();
            }
            return sb.toString();
        }

        boolean eof() {
            return cur == -1;
        }
    }

    class OutputWriter {

        private PrintWriter writer;

        OutputWriter(String name) throws IOException {
            if (name.equals("__std")) {
                writer = new PrintWriter(System.out);
            } else {
                writer = new PrintWriter(name);
            }
        }

        void print(String format, Object ... args) {
            writer.print(new Formatter(Locale.US).format(format, args));
        }

        void println(String format, Object ... args) {
            writer.println(new Formatter(Locale.US).format(format, args));
        }

        void print(Object value) {
            writer.print(value);
        }

        void println(Object value) {
            writer.println(value);
        }

        void println() {
            writer.println();
        }

        void flush() {
            writer.flush();
        }

        void close() {
            writer.close();
        }
    }
}


import java.io.*;
import java.util.*;

public class D {

    void solve() throws IOException {
        in = new InputReader("__std");
        out = new OutputWriter("__std");

        int n = in.readInt();
        int k = in.readInt();
        int a = in.readInt();
        int b = in.readInt();
        int c = in.readInt();
        int d = in.readInt();
        if (n < 5 || k < n + 1) {
            out.println(-1);
        } else {
            int[] p = new int[n + 1];
            p[a] = p[b] = p[c] = p[d] = -1;
            int e = 1;
            while (p[e] == -1) ++e;
            int f = n;
            while (p[f] == -1) --f;
            p[e] = p[f] = -2;
            int u = f;
            for (int i = 0; i < n - 6; ++i) {
                int v = 1;
                while (p[v] != 0) ++v;
                p[v] = u;
                u = v;
            }
            p[e] = u;

            out.print(a + " " + c + " ");
            u = e;
            while (u > 0) {
                out.print(u + " ");
                u = p[u];
            }
            out.println(d + " " + b);

            out.print(c + " " + a + " ");
            u = e;
            while (u > 0) {
                out.print(u + " ");
                u = p[u];
            }
            out.println(b + " " + d);
        }

        exit();
    }

    void exit() {
        //System.err.println((System.currentTimeMillis() - startTime) + " ms");
        out.close();
        System.exit(0);
    }

    InputReader in;
    OutputWriter out;

    //long startTime = System.currentTimeMillis();

    public static void main(String[] args) throws IOException {
        new D().solve();
    }

    class InputReader {

        private InputStream stream;

        private byte[] buffer = new byte[1024];
        private int pos, len;

        private int cur;

        private StringBuilder sb = new StringBuilder(32);

        InputReader(String name) throws IOException {
            if (name.equals("__std")) {
                stream = System.in;
            } else {
                stream = new FileInputStream(name);
            }
            cur = read();
        }

        private int read() throws IOException {
            if (len == -1) {
                throw new EOFException();
            }
            if (pos >= len) {
                pos = 0;
                len = stream.read(buffer);
                if (len == -1) return -1;
            }
            return buffer[pos++];
        }

        private boolean whitespace() {
            return cur == ' ' || cur == '\t' || cur == '\r' || cur == '\n' || cur == -1;
        }

        char readChar() throws IOException {
            if (cur == -1) {
                throw new EOFException();
            }
            char res = (char) cur;
            cur = read();
            return res;
        }

        int readInt() throws IOException {
            if (cur == -1) {
                throw new EOFException();
            }
            while (whitespace()) {
                cur = read();
            }
            if (cur == -1) {
                throw new EOFException();
            }
            int sign = 1;
            if (cur == '-') {
                sign = -1;
                cur = read();
            }
            int res = 0;
            while (!whitespace()) {
                if (cur < '0' || cur > '9') {
                    throw new NumberFormatException();
                }
                res *= 10;
                res += cur - '0';
                cur = read();
            }
            return res * sign;
        }

        long readLong() throws IOException {
            if (cur == -1) {
                throw new EOFException();
            }
            return Long.parseLong(readToken());
        }

        double readDouble() throws IOException {
            if (cur == -1) {
                throw new EOFException();
            }
            return Double.parseDouble(readToken());
        }

        String readLine() throws IOException {
            if (cur == -1) {
                throw new EOFException();
            }
            sb.setLength(0);
            while (cur != -1 && cur != '\r' && cur != '\n') {
                sb.append((char) cur);
                cur = read();
            }
            if (cur == '\r') {
                cur = read();
            }
            if (cur == '\n') {
                cur = read();
            }
            return sb.toString();
        }

        String readToken() throws IOException {
            if (cur == -1) {
                throw new EOFException();
            }
            while (whitespace()) {
                cur = read();
            }
            if (cur == -1) {
                throw new EOFException();
            }
            sb.setLength(0);
            while (!whitespace()) {
                sb.append((char) cur);
                cur = read();
            }
            return sb.toString();
        }

        boolean eof() {
            return cur == -1;
        }
    }

    class OutputWriter {

        private PrintWriter writer;

        OutputWriter(String name) throws IOException {
            if (name.equals("__std")) {
                writer = new PrintWriter(System.out);
            } else {
                writer = new PrintWriter(name);
            }
        }

        void print(String format, Object ... args) {
            writer.print(new Formatter(Locale.US).format(format, args));
        }

        void println(String format, Object ... args) {
            writer.println(new Formatter(Locale.US).format(format, args));
        }

        void print(Object value) {
            writer.print(value);
        }

        void println(Object value) {
            writer.println(value);
        }

        void println() {
            writer.println();
        }

        void flush() {
            writer.flush();
        }

        void close() {
            writer.close();
        }
    }
}


import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class D {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);
	static boolean debug = false;

	static void solve() {
		int n = in.nextInt();
		int k = in.nextInt();
		int[] a = new int[4];
		for (int i=0; i<4; i++) {
			a[i] = in.nextInt();
		}
		if (k - n < 1 || n == 4) {
			out.println("-1");
			return;
		}

		ArrayList<Integer> list = new ArrayList<>();
		for (int i=1; i<=n; i++) {
			boolean f = true;
			for (int j=0; j<4; j++) {
				if (a[j] == i) f = false;
			}
			if (f) {
				list.add(i);
			}
		}

		out.print(a[0]+" "+a[2]+" ");
		for (int i : list) {
			out.print(i+" ");
		}
		out.println(a[3]+" "+a[1]);

		out.print(a[2]+" "+a[0]+" ");
		for (int i : list) {
			out.print(i+" ");
		}
		out.println(a[1]+" "+a[3]);
	}

	public static void main(String[] args) {
		debug = args.length > 0;
		long start = System.currentTimeMillis();

		solve();
		out.flush();

		long end = System.currentTimeMillis();
		dump((end-start) + "ms");
		in.close();
		out.close();
	}

	static void dump(Object... o) { if (debug) System.err.println(Arrays.deepToString(o)); }
}


import java.io.*;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            int a = in.nextInt();
            int b = in.nextInt();
            int c = in.nextInt();
            int d = in.nextInt();
            if(n == 4 || k < n+1){
                out.println(-1);
                return;
            }
            out.print(a + " " + c + " ");
            boolean flag = false;
            int x = 0;
            for(int i=1;i<=n;i++){
                if(!flag && i != a && i != b && i != c && i != d){
                    x = i;
                    out.print(i + " " + d);
                    flag =true;
                }else if(flag && i != a && i != b && i != c && i != d){
                    out.print(" " + i);
                }
            }
            out.print(" " + b + "\n");
            out.print(c + " " + a + " " + x + " " + b);
            for(int i=n;i>0;i--){
                if(i != a && i != b && i != c && i != d && i != x) {
                    out.print(" " + i);
                }
            }
            out.print(" " + d);
        }
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}


import java.io.*;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            int a = in.nextInt();
            int b = in.nextInt();
            int c = in.nextInt();
            int d = in.nextInt();
            if(k < n+1){
                out.println(-1);
                return;
            }
            out.print(a + " " + c + " ");
            boolean flag = false;
            int x = 0;
            for(int i=1;i<=n;i++){
                if(!flag && i != a && i != b && i != c && i != d){
                    x = i;
                    out.print(i + " " + d);
                    flag =true;
                }else if(flag && i != a && i != b && i != c && i != d){
                    out.print(" " + i);
                }
            }
            out.print(" " + b + "\n");
            out.print(c + " " + a + " " + x + " " + b);
            for(int i=n;i>0;i--){
                if(i != a && i != b && i != c && i != d && i != x) {
                    out.print(" " + i);
                }
            }
            out.print(" " + d);
        }
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}


import java.io.*;
import java.util.*;

public class Main {
	FastReader scn;
	PrintWriter out;
	String INPUT = "";

	void solve() {
		int n = scn.nextInt(), k = scn.nextInt();
		if(k < n + 1) {
			out.println(-1);
			return;
		}

		int a = scn.nextInt(), b = scn.nextInt(), c = scn.nextInt(), d = scn.nextInt();
		StringBuilder sq = new StringBuilder();
		for(int i = 1; i <= n; i++) {
			if(i != a && i != b && i != c && i != d) {
				sq.append(i + " ");
			}
		}
		out.println(a + " " + c + " " + sq + d + " " + b);
		out.println(c + " " + a + " " + sq + b + " " + d);
	}

	void run() throws Exception {
		long time = System.currentTimeMillis();
		boolean oj = System.getProperty("ONLINE_JUDGE") != null;
		out = new PrintWriter(System.out);
		scn = new FastReader(oj);
		solve();
		out.flush();
		if (!oj) {
			System.out.println(Arrays.deepToString(new Object[] { System.currentTimeMillis() - time + " ms" }));
		}
	}

	public static void main(String[] args) throws Exception {
		new Main().run();
	}

	class FastReader {
		InputStream is;

		public FastReader(boolean onlineJudge) {
			is = onlineJudge ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		}

		byte[] inbuf = new byte[1024];
		public int lenbuf = 0, ptrbuf = 0;

		int readByte() {
			if (lenbuf == -1)
				throw new InputMismatchException();
			if (ptrbuf >= lenbuf) {
				ptrbuf = 0;
				try {
					lenbuf = is.read(inbuf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return -1;
			}
			return inbuf[ptrbuf++];
		}

		boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		int skip() {
			int b;
			while ((b = readByte()) != -1 && isSpaceChar(b))
				;
			return b;
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		char nextChar() {
			return (char) skip();
		}

		String next() {
			int b = skip();
			StringBuilder sb = new StringBuilder();
			while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		String nextLine() {
			int b = skip();
			StringBuilder sb = new StringBuilder();
			while ((!isSpaceChar(b) || b == ' ')) { // when nextLine, (isSpaceChar(b) && b != ' ')
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		char[] next(int n) {
			char[] buf = new char[n];
			int b = skip(), p = 0;
			while (p < n && !(isSpaceChar(b))) {
				buf[p++] = (char) b;
				b = readByte();
			}
			return n == p ? buf : Arrays.copyOf(buf, p);
		}

		int nextInt() {
			int num = 0, b;
			boolean minus = false;
			while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
				;
			if (b == '-') {
				minus = true;
				b = readByte();
			}

			while (true) {
				if (b >= '0' && b <= '9') {
					num = num * 10 + (b - '0');
				} else {
					return minus ? -num : num;
				}
				b = readByte();
			}
		}

		long nextLong() {
			long num = 0;
			int b;
			boolean minus = false;
			while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
				;
			if (b == '-') {
				minus = true;
				b = readByte();
			}

			while (true) {
				if (b >= '0' && b <= '9') {
					num = num * 10 + (b - '0');
				} else {
					return minus ? -num : num;
				}
				b = readByte();
			}
		}

		char[][] nextMatrix(int n, int m) {
			char[][] map = new char[n][];
			for (int i = 0; i < n; i++)
				map[i] = next(m);
			return map;
		}

		int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		int[][] next2DInt(int n, int m) {
			int[][] arr = new int[n][];
			for (int i = 0; i < n; i++) {
				arr[i] = nextIntArray(m);
			}
			return arr;
		}

		long[][] next2DLong(int n, int m) {
			long[][] arr = new long[n][];
			for (int i = 0; i < n; i++) {
				arr[i] = nextLongArray(m);
			}
			return arr;
		}

		int[] shuffle(int[] arr) {
			Random r = new Random();
			for (int i = 1, j; i < arr.length; i++) {
				j = r.nextInt(i);
				arr[i] = arr[i] ^ arr[j];
				arr[j] = arr[i] ^ arr[j];
				arr[i] = arr[i] ^ arr[j];
			}
			return arr;
		}
	}
}


import java.io.*;
import java.util.*;

public class Main {
	FastReader scn;
	PrintWriter out;
	String INPUT = "";

	void solve() {
		int n = scn.nextInt(), k = scn.nextInt();
		if(k < n + 1) {
			out.println(-1);
			return;
		}

		int a = scn.nextInt(), b = scn.nextInt(), c = scn.nextInt(), d = scn.nextInt();
		ArrayList<Integer> list = new ArrayList<>();
		for(int i = 1; i <= n; i++) {
			if(i != a && i != b && i != c && i != d) {
				list.add(i);
			}
		}
		ArrayList<Integer> l1 = new ArrayList<>();
		l1.add(a);
		l1.add(c);
		l1.addAll(list);
		l1.add(d);
		l1.add(b);

		ArrayList<Integer> l2 = new ArrayList<>();
		l2.add(c);
		l2.add(a);
		l2.addAll(list);
		l2.add(b);
		l2.add(d);

		boolean fail = false;
		for(int i = 1; i < n && !fail; i++) {
			if((l2.get(i) == a && l2.get(i - 1) == b) || (l2.get(i) == b && l2.get(i - 1) == a)) {
				fail = true;
			}
			if((l1.get(i) == c && l1.get(i - 1) == d) || (l1.get(i) == d && l1.get(i - 1) == c)) {
				fail = true;
			}
		}

		if(fail) {
			out.println(-1);
		} else {
			for(int x : l1) {
				out.print(x + " ");
			}
			out.println();
			for(int x : l2) {
				out.print(x + " ");
			}
			out.println();
		}
	}

	void run() throws Exception {
		long time = System.currentTimeMillis();
		boolean oj = System.getProperty("ONLINE_JUDGE") != null;
		out = new PrintWriter(System.out);
		scn = new FastReader(oj);
		solve();
		out.flush();
		if (!oj) {
			System.out.println(Arrays.deepToString(new Object[] { System.currentTimeMillis() - time + " ms" }));
		}
	}

	public static void main(String[] args) throws Exception {
		new Main().run();
	}

	class FastReader {
		InputStream is;

		public FastReader(boolean onlineJudge) {
			is = onlineJudge ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		}

		byte[] inbuf = new byte[1024];
		public int lenbuf = 0, ptrbuf = 0;

		int readByte() {
			if (lenbuf == -1)
				throw new InputMismatchException();
			if (ptrbuf >= lenbuf) {
				ptrbuf = 0;
				try {
					lenbuf = is.read(inbuf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return -1;
			}
			return inbuf[ptrbuf++];
		}

		boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		int skip() {
			int b;
			while ((b = readByte()) != -1 && isSpaceChar(b))
				;
			return b;
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		char nextChar() {
			return (char) skip();
		}

		String next() {
			int b = skip();
			StringBuilder sb = new StringBuilder();
			while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		String nextLine() {
			int b = skip();
			StringBuilder sb = new StringBuilder();
			while ((!isSpaceChar(b) || b == ' ')) { // when nextLine, (isSpaceChar(b) && b != ' ')
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		char[] next(int n) {
			char[] buf = new char[n];
			int b = skip(), p = 0;
			while (p < n && !(isSpaceChar(b))) {
				buf[p++] = (char) b;
				b = readByte();
			}
			return n == p ? buf : Arrays.copyOf(buf, p);
		}

		int nextInt() {
			int num = 0, b;
			boolean minus = false;
			while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
				;
			if (b == '-') {
				minus = true;
				b = readByte();
			}

			while (true) {
				if (b >= '0' && b <= '9') {
					num = num * 10 + (b - '0');
				} else {
					return minus ? -num : num;
				}
				b = readByte();
			}
		}

		long nextLong() {
			long num = 0;
			int b;
			boolean minus = false;
			while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
				;
			if (b == '-') {
				minus = true;
				b = readByte();
			}

			while (true) {
				if (b >= '0' && b <= '9') {
					num = num * 10 + (b - '0');
				} else {
					return minus ? -num : num;
				}
				b = readByte();
			}
		}

		char[][] nextMatrix(int n, int m) {
			char[][] map = new char[n][];
			for (int i = 0; i < n; i++)
				map[i] = next(m);
			return map;
		}

		int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		int[][] next2DInt(int n, int m) {
			int[][] arr = new int[n][];
			for (int i = 0; i < n; i++) {
				arr[i] = nextIntArray(m);
			}
			return arr;
		}

		long[][] next2DLong(int n, int m) {
			long[][] arr = new long[n][];
			for (int i = 0; i < n; i++) {
				arr[i] = nextLongArray(m);
			}
			return arr;
		}

		int[] shuffle(int[] arr) {
			Random r = new Random();
			for (int i = 1, j; i < arr.length; i++) {
				j = r.nextInt(i);
				arr[i] = arr[i] ^ arr[j];
				arr[j] = arr[i] ^ arr[j];
				arr[i] = arr[i] ^ arr[j];
			}
			return arr;
		}
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

/**
 * Created by vikas.k on 27/11/16.
 */
public class TaskD {
    public static void main(String[] args){
        MyScanner sc = new MyScanner();

        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] vt = new int[4];

        for(int i=0;i<4;i++){
            vt[i] = sc.nextInt();
        }

        if(n==4 || k<=n) System.out.print(-1);
        else{
            List<Integer> str = new ArrayList<>();

            for(int i=1;i<=n;i++){
                int chk =0;
                for(int j=0;j<4;j++){
                    if(vt[j] == i){
                        chk++;
                        break;
                    }
                }

                if(chk == 0){
                    str.add(i);
                }
            }

            System.out.print(vt[0]+ " " + vt[2]+ " ");
            for (int j: str) {
                System.out.print(j+" ");
            }
            System.out.println(vt[3]+ " " + vt[1]);

            System.out.print(vt[2]+ " " + vt[0]+ " ");
            for (int j: str) {
                System.out.print(j+" ");
            }
            System.out.println(vt[1]+ " " + vt[3]);
        }
    }

    private static class MyScanner{
        BufferedReader bufferedReader;
        StringTokenizer stringTokenizer;

        private MyScanner(){
            bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        }

        private String next(){
            if(stringTokenizer == null || !stringTokenizer.hasMoreElements()){
                try {
                    stringTokenizer = new StringTokenizer(bufferedReader.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return stringTokenizer.nextToken();
        }

        private int nextInt(){
            return Integer.parseInt(next());
        }
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

/**
 * Created by vikas.k on 27/11/16.
 */
public class TaskD {
    public static void main(String[] args){
        MyScanner sc = new MyScanner();

        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] vt = new int[4];

        for(int i=0;i<4;i++){
            vt[i] = sc.nextInt();
        }

        if(n==4 || k<n) System.out.print(-1);
        else{
            List<Integer> str = new ArrayList<>();

            for(int i=1;i<=n;i++){
                int chk =0;
                for(int j=0;j<4;j++){
                    if(vt[j] == i){
                        chk++;
                        break;
                    }
                }

                if(chk == 0){
                    str.add(i);
                }
            }

            System.out.print(vt[0]+ " " + vt[2]+ " ");
            for (int j: str) {
                System.out.print(j+" ");
            }
            System.out.println(vt[3]+ " " + vt[1]);

            System.out.print(vt[2]+ " " + vt[0]+ " ");
            for (int j: str) {
                System.out.print(j+" ");
            }
            System.out.println(vt[1]+ " " + vt[3]);
        }
    }

    private static class MyScanner{
        BufferedReader bufferedReader;
        StringTokenizer stringTokenizer;

        private MyScanner(){
            bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        }

        private String next(){
            if(stringTokenizer == null || !stringTokenizer.hasMoreElements()){
                try {
                    stringTokenizer = new StringTokenizer(bufferedReader.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return stringTokenizer.nextToken();
        }

        private int nextInt(){
            return Integer.parseInt(next());
        }
    }
}


import java.io.*;
import java.util.InputMismatchException;

public class Cf1805D {
    private static InputReader in = new InputReader(System.in);
    private static OutputWriter out = new OutputWriter(System.out);

    private static void solve() throws Exception{
        int n = in.readInt();
        int k = in.readInt();
        int a = in.readInt();
        int b = in.readInt();
        int c = in.readInt();
        int d = in.readInt();
        boolean[]  flags = new boolean[n+1];
        flags[a] = true;
        flags[b] = true;
        flags[c] = true;
        flags[d] = true;
        if(k<n){
            out.println(-1);
            return;
        }
        String base = "";
        for(int i=1; i<=n; ++i){
            if(flags[i]){
                continue;
            }
            base += (i+" ");
        }
        out.println(a+" "+d+" "+c+" "+base+b);
        out.println(c+" "+base+b+" "+a+" "+d);

    }

    public static void main(String[] args) throws Exception {
        solve();
        out.close();
    }

    private static class InputReader {
        private InputStream stream;
        private byte[] buffer;
        private int currentIndex;
        private int bytesRead;

        public InputReader(InputStream stream) {
            this.stream = stream;
            buffer = new byte[131072];
        }

        public InputReader(InputStream stream, int bufferSize) {
            this.stream = stream;
            buffer = new byte[bufferSize];
        }

        private int read() throws IOException {
            if (currentIndex >= bytesRead) {
                currentIndex = 0;
                bytesRead = stream.read(buffer);
                if (bytesRead <= 0) {
                    return -1;
                }
            }
            return buffer[currentIndex++];
        }

        public String readString() throws IOException {
            int c = read();
            while (!isPrintable(c)) {
                c = read();
            }
            StringBuilder result = new StringBuilder();
            do {
                result.appendCodePoint(c);
                c = read();
            } while (isPrintable(c));
            return result.toString();
        }

        public int readInt() throws Exception {
            int c = read();
            int sign = 1;
            while (!isPrintable(c)) {
                c = read();
            }
            if (c == '-') {
                sign = -1;
                c = read();
            }
            int result = 0;
            do {
                if ((c < '0') || (c > '9')) {
                    throw new InputMismatchException();
                }
                result *= 10;
                result += (c - '0');
                c = read();
            } while (isPrintable(c));
            return sign * result;
        }

        public long readLong() throws Exception {
            int c = read();
            int sign = 1;
            while (!isPrintable(c)) {
                c = read();
            }
            if (c == '-') {
                sign = -1;
                c = read();
            }
            long result = 0;
            do {
                if ((c < '0') || (c > '9')) {
                    throw new InputMismatchException();
                }
                result *= 10;
                result += (c - '0');
                c = read();
            } while (isPrintable(c));
            return sign * result;
        }

        public double readDouble() throws Exception {
            int c = read();
            int sign = 1;
            while (!isPrintable(c)) {
                c = read();
            }
            if (c == '-') {
                sign = -1;
                c = read();
            }
            boolean fraction = false;
            double multiplier = 1;
            double result = 0;
            do {
                if ((c == 'e') || (c == 'E')) {
                    return sign * result * Math.pow(10, readInt());
                }
                if ((c < '0') || (c > '9')) {
                    if ((c == '.') && (!fraction)) {
                        fraction = true;
                        c = read();
                        continue;
                    }
                    throw new InputMismatchException();
                }
                if (fraction) {
                    multiplier /= 10;
                    result += (c - '0') * multiplier;
                    c = read();
                } else {
                    result *= 10;
                    result += (c - '0');
                    c = read();
                }
            } while (isPrintable(c));
            return sign * result;
        }

        private boolean isPrintable(int c) {
            return ((c > 32) && (c < 127));
        }
    }

    private static class OutputWriter {
        private PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void print(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                if (i != 0) {
                    writer.print(' ');
                }
                writer.print(objects[i]);
            }
        }

        public void println(Object... objects) {
            print(objects);
            writer.println();
        }

        public void close() {
            writer.close();
        }

        public void flush() {
            writer.flush();
        }
    }
}