#include <bits/stdc++.h>
using namespace std;
void solve() {
  string s;
  cin >> s;
  long long cnt = 0, ud = 0;
  for (long long i = 0; i < s.size(); i++) {
    if (s[i] == ':') {
      ud = 0;
      continue;
    }
    if (ud == 1) continue;
    if (ud == 0) {
      cnt++;
      ud = 1;
    }
  }
  long long add = 8 - cnt;
  vector<string> v;
  for (long long i = 0; i < s.size();) {
    if (i + 1 < s.size() && s[i] == ':' && s[i + 1] == ':') {
      while (add--) v.push_back("0000");
      i++;
      continue;
    }
    string t;
    if (i != 0) i++;
    while (i < s.size() && s[i] != ':') {
      t.push_back(s[i]);
      i++;
    }
    v.push_back(t);
  }
  for (long long i = 0; i < 8; i++) {
    long long n = 4 - v[i].size();
    for (long long j = 0; j < n; j++) cout << 0;
    for (long long j = 0; j < v[i].size(); j++) cout << v[i][j];
    if (i != 7) cout << ":";
  }
  cout << endl;
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
