Problem: One day Maria Ivanovna found a Sasha's piece of paper with a message dedicated to Olya. Maria Ivanovna wants to know what is there in a message, but unfortunately the message is ciphered. Maria Ivanovna knows that her students usually cipher their messages by replacing each letter of an original message by some another letter. Replacement works in such way that same letters are always replaced with some fixed letter, and different letters are always replaced by different letters. 

Maria Ivanovna supposed that the message contains answers to the final exam (since its length is equal to the number of final exam questions). On the other hand she knows that Sasha's answer are not necessary correct. There are K possible answers for each questions. Of course, Maria Ivanovna knows correct answers.

Maria Ivanovna decided to decipher message in such way that the number of Sasha's correct answers is maximum possible. She is very busy now, so your task is to help her.

Input

First line contains length of both strings N (1 ≤ N ≤ 2 000 000) and an integer K — number of possible answers for each of the questions (1 ≤ K ≤ 52). Answers to the questions are denoted as Latin letters abcde...xyzABCDE...XYZ in the order. For example for K = 6, possible answers are abcdef and for K = 30 possible answers are abcde...xyzABCD.

Second line contains a ciphered message string consisting of Latin letters.

Third line contains a correct answers string consisting of Latin letters.

Output

In the first line output maximum possible number of correct Sasha's answers.

In the second line output cipher rule as the string of length K where for each letter from the students' cipher (starting from 'a' as mentioned above) there is specified which answer does it correspond to.

If there are several ways to produce maximum answer, output any of them.

Examples

Input

10 2
aaabbbaaab
bbbbabbbbb


Output

7
ba


Input

10 2
aaaaaaabbb
bbbbaaabbb


Output

6
ab


Input

9 4
dacbdacbd
acbdacbda


Output

9
cdba

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
struct vertex {
  vector<int> n, c, f, r, w;
  int t, b, d;
  pair<int, int> pr;
};
vector<vertex> g;
int s, t, n;
const int MAXN = 2000000, MAXK = 52;
int dfs(int i, int f) {
  if (i == t) {
    return f;
  }
  g[i].t = 1;
  for (int j = 0; j < g[i].n.size(); ++j) {
    if (!g[g[i].n[j]].t && g[i].c[j] - g[i].f[j] > 0) {
      int k = dfs(g[i].n[j], min(f, g[i].c[j] - g[i].f[j]));
      if (k) {
        g[i].f[j] += k;
        g[g[i].n[j]].f[g[i].r[j]] -= k;
        return k;
      }
    }
  }
  return 0;
}
void edge(int a, int b, int c, int d, int f) {
  g[a].n.push_back(b);
  g[b].n.push_back(a);
  g[a].c.push_back(c);
  g[b].c.push_back(0);
  g[a].f.push_back(f);
  g[b].f.push_back(-f);
  g[a].r.push_back(g[b].n.size() - 1);
  g[b].r.push_back(g[a].n.size() - 1);
  g[a].w.push_back(d);
  g[b].w.push_back(-d);
}
int dej() {
  int i, j;
  set<pair<int, int>> dist;
  for (i = 0; i < n; ++i) {
    if (i == s) {
      dist.insert(make_pair(0, s));
      g[i].d = 0;
    } else {
      dist.insert(make_pair(1e9, i));
      g[i].d = 1e9;
    }
    g[i].t = 0;
  }
  g[s].pr = make_pair(-1, -1);
  while (!dist.empty() && dist.begin()->first != 1e9) {
    j = dist.begin()->second;
    g[j].t = 1;
    for (i = 0; i < g[j].n.size(); ++i) {
      if (!g[g[j].n[i]].t && g[j].c[i] - g[j].f[i] > 0 &&
          g[g[j].n[i]].d > g[j].d + g[j].w[i]) {
        dist.erase(dist.find(make_pair(g[g[j].n[i]].d, g[j].n[i])));
        g[g[j].n[i]].d = g[j].d + g[j].w[i];
        g[g[j].n[i]].pr = make_pair(j, i);
        dist.insert(make_pair(g[g[j].n[i]].d, g[j].n[i]));
      }
    }
    dist.erase(dist.begin());
  }
  if (g[t].d == 1e9) {
    return 0;
  }
  j = 1e9;
  for (i = t; i >= 0; i = g[i].pr.first) {
    if (g[i].pr.first != -1) {
      j = min(j, g[g[i].pr.first].c[g[i].pr.second] -
                     g[g[i].pr.first].f[g[i].pr.second]);
    }
  }
  for (i = t; i >= 0; i = g[i].pr.first) {
    if (g[i].pr.first != -1) {
      g[g[i].pr.first].f[g[i].pr.second] += j;
      g[i].f[g[g[i].pr.first].r[g[i].pr.second]] -= j;
    }
  }
  return 1;
}
int dist[2 * MAXK + 2][2 * MAXK + 2], pr[2 * MAXK + 2][2 * MAXK + 2], aa = 0;
int fl() {
  int i, j, k, h = -1;
  ++aa;
  for (i = 0; i < n; ++i) {
    for (j = 0; j < n; ++j) {
      dist[i][j] = 1e9;
    }
    dist[i][i] = 0;
  }
  for (i = 0; i < n; ++i) {
    for (j = 0; j < g[i].n.size(); ++j) {
      if (g[i].c[j] - g[i].f[j] > 0) {
        dist[i][g[i].n[j]] = g[i].w[j];
        pr[i][g[i].n[j]] = j;
      }
    }
  }
  for (k = 0; k < n; ++k) {
    for (i = 0; i < n; ++i) {
      for (j = 0; j < n; ++j) {
        if (dist[i][k] != 1e9 && dist[k][j] != 1e9 &&
            dist[i][j] > dist[i][k] + dist[k][j]) {
          dist[i][j] = dist[i][k] + dist[k][j];
          pr[i][j] = pr[i][k];
        }
      }
    }
    for (i = 0; i < n; ++i) {
      if (dist[i][i] < 0) {
        h = i;
        break;
      }
    }
    if (i < n) {
      break;
    }
  }
  if (h == -1) {
    return 0;
  }
  i = g[h].n[pr[h][h]];
  k = g[h].c[pr[h][h]] - g[h].f[pr[h][h]];
  while (i != h) {
    k = min(k, g[i].c[pr[i][h]] - g[i].f[pr[i][h]]);
    i = g[i].n[pr[i][h]];
  }
  i = g[h].n[pr[h][h]];
  g[h].f[pr[h][h]] += k;
  g[i].f[g[h].r[pr[h][h]]] -= k;
  while (i != h) {
    g[i].f[pr[i][h]] += k;
    g[g[i].n[pr[i][h]]].f[g[i].r[pr[i][h]]] -= k;
    i = g[i].n[pr[i][h]];
  }
  return 1;
}
char s1[MAXN], s2[MAXN];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int m, i, j, k, h, r, c, ans = 0, w;
  string ansc;
  vector<vector<int>> v;
  cin >> n >> w;
  for (i = 0; i < n; ++i) {
    cin >> s1[i];
  }
  for (i = 0; i < n; ++i) {
    cin >> s2[i];
  }
  v.resize(w);
  for (i = 0; i < w; ++i) {
    v[i].resize(w, 0);
  }
  h = n;
  n = 2 * w + 2;
  s = 0;
  t = n - 1;
  g.resize(n);
  for (i = 0; i < h; ++i) {
    j = i;
    if ('a' <= s1[i] && s1[i] <= 'z') {
      r = s1[i] - 'a';
    } else {
      r = s1[i] - 'A' + 26;
    }
    if ('a' <= s2[j] && s2[j] <= 'z') {
      k = s2[j] - 'a';
    } else {
      k = s2[j] - 'A' + 26;
    }
    ++v[r][k];
  }
  for (i = 0; i < w; ++i) {
    for (j = 0; j < w; ++j) {
      if (i == j) {
        edge(i + 1, j + w + 1, 1, -v[i][j], 1);
      } else {
        edge(i + 1, j + w + 1, 1, -v[i][j], 0);
      }
    }
  }
  for (i = 0; i < w; ++i) {
    edge(0, i + 1, 1, 0, 1);
    edge(i + w + 1, 2 * w + 1, 1, 0, 1);
  }
  while (fl()) {
  }
  for (i = 0; i < w; ++i) {
    for (j = 0; j < g[i + 1].n.size(); ++j) {
      if (g[i + 1].f[j] > 0) {
        k = g[i + 1].n[j];
        if (k - w - 1 < 26) {
          ansc.push_back('a' + k - w - 1);
        } else {
          ansc.push_back('A' + k - w - 1 - 26);
        }
        ans -= g[i + 1].w[j];
        break;
      }
    }
  }
  cout << ans << endl << ansc << endl;
}