#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
const long long INF = 1e18;
using namespace std;
long long hcf(long long a, long long b) {
  if (b == 0) return a;
  return hcf(b, a % b);
}
unsigned long long stringtoll(string s) {
  unsigned long long ans = 0;
  for (unsigned long long i = 0; i < s.length(); i++) {
    ans = ans * 10 + (s[i] - '0');
  }
  return ans;
}
vector<long long> root(long long n) {
  vector<long long> ans;
  for (long long i = 2; i <= sqrt(n); i++) {
    if (n % i == 0) {
      ans.push_back(i);
      if (i != n / i) ans.push_back(n / i);
    }
  }
  return ans;
}
bool ifprime(long long n) {
  for (int i = 2; i <= sqrt(n); i++) {
    if (n % i == 0) return false;
  }
  return true;
}
long long logat(long long n, long long base) { return (log(n) / log(base)); }
long long factorial(long long n) {
  if (n == 0) return 1;
  return (n * factorial(n - 1)) % 1000000007;
}
void baspri(bool flag) {
  if (flag)
    cout << "YES"
         << "\n";
  else
    cout << "NO"
         << "\n";
}
long long lcm(long long a, long long b) { return (a / hcf(a, b)) * b; }
vector<pair<long long, long long>> prime_fact(long long n) {
  vector<pair<long long, long long>> ans;
  for (long long i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      long long another = 0;
      while (n % i == 0) {
        n = n / i;
        another++;
      }
      ans.push_back({i, another});
    }
  }
  if (n > 1) ans.push_back({n, 1});
  return ans;
}
long long pw(long long n, long long r, long long mop) {
  long long res = 1;
  while (r != 0) {
    if (r % 2) {
      res = (res * n) % mop;
      r--;
    }
    n = (n * n) % mop;
    r = r / 2;
  }
  return res;
}
int query(int a, int b) {
  cout << "? " << a << " " << b << "\n";
  cout.flush();
  int t;
  cin >> t;
  return t;
}
const int N = 1e3 + 5;
long long n, m, k;
vector<long long> adj[N];
vector<long long> vis(N, false);
vector<long long> spe(N, false);
long long op = 0;
bool dfs(long long node) {
  vis[node] = true;
  op++;
  bool flag = false;
  for (auto i : adj[node]) {
    if (vis[i]) continue;
    if (dfs(i)) flag = true;
  }
  if (flag || spe[node]) return true;
  return false;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  {
    string a, b;
    cin >> a >> b;
    map<char, char> m;
    for (long long i = 0; i < a.length(); i++) {
      if (!m.count(a[i]) && !m.count(b[i])) {
        m[a[i]] = b[i];
        m[b[i]] = a[i];
      } else if (m[a[i]] != b[i]) {
        cout << -1 << "\n";
        return 0;
      }
    }
    set<char> s;
    vector<pair<char, char>> ans;
    for (auto i : m) {
      char op1 = i.first;
      char op2 = i.second;
      if (op1 == op2) continue;
      if (s.find(op1) == s.end()) {
        ans.push_back({op1, op2});
        s.insert(op1);
        s.insert(op2);
      }
    }
    cout << ans.size() << "\n";
    for (auto i : ans) {
      cout << i.first << " " << i.second << "\n";
    }
  }
}
