#include <bits/stdc++.h>
#ifndef ONLINE_JUDGE
#include "debug.h"
#else
#define debug(...)
#endif
#define int long long
#define oo LLONG_MAX >> 2
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define pb push_back
#define pep_Guardiola      \
  ios::sync_with_stdio(0); \
  cin.tie(0);              \
  cout.tie(0);
using namespace std;
void io()
{
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
#endif
}
int n;
struct Trie
{
  struct Node
  {
    int freq;
    string s = "";
    map<string, int> id;
    bool end = 0;
    Node() = default;
  };
  vector<Node> trie;
  Trie() : trie(1) {}
  void insert(const vector<string> &s)
  {
    int node = 0;
    int n = s.size();
    for (int i = 0; i < n; i++)
    {
      string cVal = s[i];
      if (!trie[node].id.count(cVal))
      {
        int cur = trie.size();
        trie.emplace_back();
        trie[node].id[cVal] = cur;
        trie[cur].s = s[i];
        trie[cur].id[trie[node].s] = node;
      }
      node = trie[node].id[cVal];
      trie[node].freq++;
    }
    trie[node].end = 1;
  }

  int find(int node, int pr)
  {
    for (auto [k, v] : trie[node].id)
    {
      // cout << trie[v].freq << endl;
      if (trie[v].freq > n / 2 && v != pr)
      {
        return find(v, node);
      }
    }
    return node;
  }

  int help(int node, int pr, int len = 0)
  {
    cout << trie[node].s << ' ';
    int ans = 0;
    for (auto [k, v] : trie[node].id)
    {
      if (v != pr)
      {
        ans += help(v, node, len + 1);
      }
    }
    cout << "Back\n";
    return ans + (trie[node].end ? len : 0);
  }
};

signed main()
{
  pep_Guardiola
  io();
  cin >> n;
  Trie tr;
  for (int i = 0; i < n; i++)
  {
    string s;
    cin >> s;
    vector<string> a;
    string cur = "";
    for (auto x : s)
    {
      if (x == '/')
      {
        if (cur != "")
          a.push_back(cur);
        cur = "";
      }
      else
        cur += x;
    }
    if (cur != "")
      a.push_back(cur);
    tr.insert(a);
  }

  int best = tr.find(0, -1);
  cout << tr.trie[best].s << ' ' << best << endl;
  cout << tr.help(best, -1, 0) << endl;
}