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 mcmfedge {
  long long flow, cap, from, to, cost, revid;
  mcmfedge(long long flow, long long cap, long long cost, int from, int to,
           int revid)
      : flow(flow), cap(cap), from(from), to(to), cost(cost), revid(revid) {}
  bool operator<(mcmfedge* other) { return cost < other->cost; }
};
struct mcmf {
  vector<mcmfedge*> edgelist;
  vector<vector<mcmfedge*> > adj;
  vector<mcmfedge*> par;
  vector<long long> potential;
  vector<long long> dist;
  priority_queue<pair<long long, mcmfedge*>,
                 vector<pair<long long, mcmfedge*> >,
                 greater<pair<long long, mcmfedge*> > >
      q;
  vector<bool> inq;
  queue<int> qu;
  int source;
  int sink;
  long long INFI = 3000000000000000000LL;
  bool calledMaxFlow = false;
  bool hasInitialNegativeEdges = false;
  int nodeNumber;
  mcmf(int nodeNumber, int source, int sink) {
    this->source = source;
    this->sink = sink;
    this->nodeNumber = nodeNumber;
    par.resize(nodeNumber);
    adj.resize(nodeNumber);
    potential.resize(nodeNumber);
    inq.resize(nodeNumber);
    dist.resize(nodeNumber);
  }
  void add_edge(int cap, int cost, int from, int to) {
    if (from >= nodeNumber || to >= nodeNumber)
      cout << "Warning: Edge from " << from << " to " << to << " with capacity"
           << cap << "is out of bounds." << endl;
    mcmfedge* v = new mcmfedge(0, cap, cost, from, to, edgelist.size() + 1);
    mcmfedge* v_rev = new mcmfedge(0, 0, -cost, to, from, edgelist.size());
    if (cost < 0) hasInitialNegativeEdges = true;
    edgelist.push_back(v);
    edgelist.push_back(v_rev);
    adj[from].push_back(v);
    adj[to].push_back(v_rev);
  }
  bool dij_aug_path() {
    for (int i = 0; i < nodeNumber; i++) par[i] = NULL, dist[i] = INFI;
    while (!q.empty()) q.pop();
    q.push(make_pair(0, new mcmfedge(0, 0, 0, source, source, -1)));
    while (!q.empty()) {
      mcmfedge* curedge = q.top().second;
      int curnode = curedge->to;
      long long curdist = q.top().first;
      q.pop();
      if (dist[curnode] == INFI) {
        par[curnode] = curedge;
        dist[curnode] = curdist;
        for (int i = 0; i < adj[curnode].size(); i++) {
          mcmfedge* cur = adj[curnode][i];
          if (cur->cap - cur->flow > 0) {
            q.push(make_pair(
                curdist + cur->cost + potential[cur->from] - potential[cur->to],
                cur));
          }
        }
      }
    }
    return dist[sink] != INFI;
  }
  bool spfa() {
    for (int i = 0; i < nodeNumber; i++)
      par[i] = NULL, dist[i] = INFI, inq[i] = false;
    while (!qu.empty()) qu.pop();
    qu.push(source);
    dist[source] = 0;
    while (!qu.empty()) {
      int curnode = qu.front();
      qu.pop();
      inq[curnode] = false;
      for (int i = 0; i < adj[curnode].size(); i++) {
        mcmfedge* cur = adj[curnode][i];
        if (dist[curnode] + cur->cost + potential[cur->from] -
                    potential[cur->to] <
                dist[cur->to] &&
            cur->cap - cur->flow > 0) {
          dist[cur->to] = dist[curnode] + cur->cost + potential[cur->from] -
                          potential[cur->to];
          par[cur->to] = adj[curnode][i];
          if (!inq[cur->to]) {
            qu.push(cur->to);
            inq[cur->to] = true;
          }
        }
      }
    }
    return dist[sink] != INFI;
  }
  pair<long long, long long> set_potentials_and_augment() {
    int curnode = sink;
    long long augment_flow = INFI;
    while (curnode != source) {
      mcmfedge* curpar = par[curnode];
      augment_flow = min(augment_flow, curpar->cap - curpar->flow);
      curnode = curpar->from;
    }
    curnode = sink;
    while (curnode != source) {
      mcmfedge* curpar = par[curnode];
      curpar->flow += augment_flow;
      edgelist[curpar->revid]->flow -= augment_flow;
      curnode = curpar->from;
    }
    for (int i = 0; i < nodeNumber; i++) {
      potential[i] = min(potential[i] + dist[i], INFI);
    }
    return make_pair(augment_flow, augment_flow * potential[sink]);
  }
  pair<long long, long long> get_mcmf(bool dospfa = false) {
    for (int i = 0; i < edgelist.size(); i++) edgelist[i]->flow = 0;
    long long mincost = 0;
    long long maxflow = 0;
    if (dospfa) {
      while (spfa()) {
        pair<long long, long long> mcmf = set_potentials_and_augment();
        mincost += mcmf.second;
        maxflow += mcmf.first;
      }
      return make_pair(maxflow, mincost);
    } else if (hasInitialNegativeEdges) {
      bool hasPath = spfa();
      if (!hasPath) return make_pair(0, 0);
      pair<long long, long long> mcmf = set_potentials_and_augment();
      mincost += mcmf.second;
      maxflow += mcmf.first;
    }
    calledMaxFlow = true;
    while (dij_aug_path()) {
      pair<long long, long long> mcmf = set_potentials_and_augment();
      mincost += mcmf.second;
      maxflow += mcmf.first;
    }
    return make_pair(maxflow, mincost);
  }
  vector<long long> get_flow_values() {
    vector<long long> flow_values;
    if (calledMaxFlow) {
      for (int i = 0; i < edgelist.size(); i += 2) {
        flow_values.push_back(edgelist[i]->flow);
      }
    } else {
      cout << "Error: cannot get flow values since get_max_flow has not been "
              "called"
           << endl;
    }
    return flow_values;
  }
  vector<long long> get_costflow_values() {
    vector<long long> flow_values;
    if (calledMaxFlow) {
      for (int i = 0; i < edgelist.size(); i += 2) {
        flow_values.push_back(edgelist[i]->flow * edgelist[i]->cost);
      }
    } else {
      cout << "Error: cannot get flow * cost values since get_max_flow has not "
              "been called"
           << endl;
    }
    return flow_values;
  }
  vector<mcmfedge*> get_edges() {
    vector<mcmfedge*> edges;
    for (int i = 0; i < edgelist.size(); i += 2) {
      edges.push_back(edgelist[i]);
    }
    return edges;
  }
};
int n, k;
string alpha = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
int letter[1000];
int gain[53][53];
string s1, s2;
char selected[53];
int main() {
  cin >> n >> k;
  for (int i = 0; i < 52; i++) letter[alpha[i]] = i;
  cin >> s1 >> s2;
  mcmf* mc = new mcmf(2 * k + 2, 0, 1);
  for (int i = 0; i < n; i++) {
    gain[letter[s1[i]]][letter[s2[i]]]++;
  }
  for (int i = 0; i < k; i++) {
    mc->add_edge(1, 0, 0, 2 + i);
    mc->add_edge(1, 0, 2 + i + k, 1);
  }
  for (int i = 0; i < k; i++) {
    for (int j = 0; j < k; j++) {
      mc->add_edge(1, -gain[i][j], 2 + i, 2 + j + k);
    }
  }
  cout << -mc->get_mcmf().second << '\n';
  vector<mcmfedge*> edges = mc->get_edges();
  for (int i = 2 * k; i < edges.size(); i++) {
    if (edges[i]->flow > 0) {
      selected[edges[i]->from - 2] = alpha[edges[i]->to - 2 - k];
    }
  }
  for (int i = 0; i < k; i++) cout << selected[i];
  cout << '\n';
}