#include <iostream>
#include <algorithm>
#include <set>
#include <string>
#include <cstdio>
#include <string>
#include <stdio.h>

using namespace std;

set <pair <int, int> > used;
set <string> w;
int tmp, cnt, all, mode, len, n, m, z[100000][2], t[100000];
string w1[100000], w2[100000];

int getrand(int k)
{
    return (rand() * 32000 + rand()) % k;
}

void gen_very_same()
{
    string s;
    for (int i = 0; i < n; i++)
    {
        int t = getrand(len / 2) + (len / 2) + 1;
        s = "";
        for (int j = 0; j < t; j++)
            s += (getrand(26) + 'a');
        while (w.find(s) != w.end())
        {
            s = "";
            for (int j = 0; j < t; j++)
                s += (getrand(26) + 'a');
        }
        w.insert(s);
        w1[i] = s;
    }
    if (m >= n)
        for (int i = 0; i < n; i++)
            w2[i] = w1[i];
    if (m < n)
        for (int i = 0; i < m; i++)
            w2[i] = w1[i];
    w.clear();
    for (int i = n; i < m; i++)
    {
        int t = getrand(len / 2) + (len / 2) + 1;
        s = "";
        for (int j = 0; j < t; j++)
            s += (getrand(26) + 'a');
        while (w.find(s) != w.end())
        {
            s = "";
            for (int j = 0; j < t; j++)
                s += (getrand(26) + 'a');
        }
        w.insert(s);
        w2[i] = s;
    }

    sort(w1, w1 + n);
    sort(w2, w2 + m);

    int p,q;
    for (int i = 0; i < all; i++)
    {
        do
        {
            p = getrand(n);
            q = getrand(m);
        } while (used.find(make_pair(p, q)) != used.end());
        used.insert(make_pair(p, q));
    }
    set <pair <int, int> >::iterator it = used.begin();
    for ( ; it != used.end(); ++it)
    {
        z[cnt][0] = it->first;
        z[cnt][1] = it->second;
        cnt++;
    }
    for (int i = 0; i < cnt; i++)
    {
        t[z[i][0]]++;
    }
    int a = 0;
    int tmp = n;
    for (int i = 0; i < n; i++)
        if (t[i] == 0)
            tmp--;
    cout << tmp << endl;
    for (int i = 0; i < n; i++)
    {
        if (t[i] == 0) continue;
        cout << w1[i] << " - ";
        for (int j = 0; j < t[i] - 1; j++)
          cout << w2[z[a+j][1]] << ", ";
        cout << w2[z[a + t[i] - 1][1]] << endl;
        a += t[i];
    }
}

void gs(string *s, string e)
{
  int k = getrand(3);
  /*string t = e;
  for (int i = 0; i < k; i++)
  {
    int q = getrand(e.size());
    *s = "";
    for (int j = 0; j < q; j++)
      *s += t[j];
    if (getrand(13) && t.size() > 3)
      *s += 'a'+char(getrand(26));
    for (int j = q + 1; j < t.size(); j++)
      *s += t[j];
    t = *s;
  }*/

  *s=e;
  for(int i = 0; i < k; i++)
  {
    int p = getrand(s->size());
    if(!getrand(13) && s->size()>=3)
      s->erase(p, 1);
    else
      (*s)[p] = char('a' + getrand(26));
  }
}

void gen_same()
{
    string s, pat;
    s = "";
    int tmp = getrand(len / 2) + (len / 2) + 1;
    for (int j = 0; j < tmp; j++)
        s += char(getrand(26) + 'a');
    pat = s;
    w.insert(s);
    w1[0] = s;
    for (int i = 1; i < n; i++)
    {
        do
            gs(&s, pat);
        while (w.find(s) != w.end());

        w.insert(s);
        w1[i] = s;
    }
    w.clear();
    s = "";
    tmp = getrand(len / 2) + (len / 2) + 1;
    for (int j = 0; j < tmp; j++)
        s += char(getrand(26) + 'a');
    pat = s;
    w.insert(s);
    w2[0] = s;
    for (int i = 1; i < m; i++)
    {
        do
            gs(&s, pat);
        while (w.find(s) != w.end());

        w.insert(s);
        w2[i] = s;
    }

    sort(w1, w1 + n);
    sort(w2, w2 + m);

    int p,q;
    for (int i = 0; i < all; i++)
    {
        do
        {
            p = getrand(n);
            q = getrand(m);
        } while (used.find(make_pair(p, q)) != used.end());
        used.insert(make_pair(p, q));
    }
    set <pair <int, int> >::iterator it = used.begin();
    for ( ; it != used.end(); ++it)
    {
        z[cnt][0] = it->first;
        z[cnt][1] = it->second;
        cnt++;
    }
    for (int i = 0; i < cnt; i++)
    {
        t[z[i][0]]++;
    }
    int a = 0;
    tmp = n;
    for (int i = 0; i < n; i++)
        if (t[i] == 0)
            tmp--;
    cout << tmp << endl;
    for (int i = 0; i < n; i++)
    {
        if (t[i] == 0) continue;
        cout << w1[i] << " - ";
        for (int j = 0; j < t[i] - 1; j++)
          cout << w2[z[a+j][1]] << ", ";
        cout << w2[z[a + t[i] - 1][1]] << endl;
        a += t[i];
    }
}

void gen_simple()
{
    string s;
    for (int i = 0; i < n; i++)
    {
        int t = getrand(len / 2) + (len / 2) + 1;
        s = "";
        for (int j = 0; j < t; j++)
            s += (getrand(26) + 'a');
        while (w.find(s) != w.end())
        {
            s = "";
            for (int j = 0; j < t; j++)
                s += (getrand(26) + 'a');
        }
        w.insert(s);
        w1[i] = s;
    }
    w.clear();
    for (int i = 0; i < m; i++)
    {
        int t = getrand(len / 2) + (len / 2) + 1;
        s = "";
        for (int j = 0; j < t; j++)
            s += (getrand(26) + 'a');
        while (w.find(s) != w.end())
        {
            s = "";
            for (int j = 0; j < t; j++)
                s += (getrand(26) + 'a');
        }
        w.insert(s);
        w2[i] = s;
    }

    sort(w1, w1 + n);
    sort(w2, w2 + m);

    int p,q;
    for (int i = 0; i < all; i++)
    {
        do
        {
            p = getrand(n);
            q = getrand(m);
        } while (used.find(make_pair(p, q)) != used.end());
        used.insert(make_pair(p, q));
    }
    set <pair <int, int> >::iterator it = used.begin();
    for ( ; it != used.end(); ++it)
    {
        z[cnt][0] = it->first;
        z[cnt][1] = it->second;
        cnt++;
    }
    for (int i = 0; i < cnt; i++)
    {
        t[z[i][0]]++;
    }
    int a = 0;
    int tmp = n;
    for (int i = 0; i < n; i++)
        if (t[i] == 0)
            tmp--;
    cout << tmp << endl;
    for (int i = 0; i < n; i++)
    {
        if (t[i] == 0) continue;
        cout << w1[i] << " - ";
        for (int j = 0; j < t[i] - 1; j++)
          cout << w2[z[a+j][1]] << ", ";
        cout << w2[z[a + t[i] - 1][1]] << endl;
        a += t[i];
    }
}

int main(int argc, char ** argv)
{
    //freopen ("input.txt", "r", stdin);
    //freopen ("voc.in", "w", stdout);
    srand(atoi(argv[1]));
    n = atoi(argv[2]);
    m = atoi(argv[3]);
    all = atoi(argv[4]);
    len = atoi(argv[5]);
    mode = atoi(argv[6]);
    all -= n;
    //scanf("%d%d%d%d%d%d", &tmp, &n, &m, &all, &len, &mode);
    //srand(tmp);
    if (mode == 0)
        gen_simple();
    if (mode == 1)
        gen_same();
    if (mode == 2)
        gen_very_same();

    return 0;
}
