#include <bits/stdc++.h>
using namespace std;
typedef priority_queue<pair<int, int>, vector<pair<int, int> >,
                       greater<pair<int, int> > >
    PQP_MIN;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  vector<string> sol;
  sol.resize(8);
  int n;
  cin >> n;
  string s;
  while (n--) {
    cin >> s;
    for (int i = 0; i < 8; i++) sol[i].clear();
    char p = '.';
    int l = 0, ind = 0;
    while (l < s.size() && (p != ':' || s[l] != ':')) {
      if (s[l] == ':')
        ind++;
      else
        sol[ind].push_back(s[l]);
      p = s[l++];
    }
    int r = s.size() - 1;
    ind = 7;
    while (r > l) {
      if (s[r] == ':')
        ind--;
      else
        sol[ind].insert(sol[ind].begin(), s[r]);
      r--;
    }
    for (int i = 0; i < 8; i++) {
      for (int j = sol[i].size(); j <= 3; j++) cout << 0;
      for (int j = 0; j < sol[i].size(); j++) cout << sol[i][j];
      if (i < 7)
        cout << ':';
      else
        cout << '\n';
    }
  }
  return 0;
}
