#include <bits/stdc++.h>
using namespace std;
string convsub(string s, int& numsec) {
  string t;
  unsigned int loc = 0;
  numsec = 0;
  if (s.size() == 0) return t;
  while (true) {
    numsec++;
    unsigned int loc2 = s.find(":", loc);
    if (loc2 == string::npos) {
      int len = s.size() - loc;
      for (int i = 0; i < 4 - len; i++) {
        t += "0";
      }
      t.append(s, loc, len);
      return t;
    }
    int len = loc2 - loc;
    for (int i = 0; i < 4 - len; i++) {
      t += "0";
    }
    t.append(s, loc, len + 1);
    loc = loc2 + 1;
  }
}
string conv(string s) {
  unsigned int loc = s.find("::", 0);
  int numsec0, numsec1;
  if (loc == string::npos) {
    return convsub(s, numsec0);
  }
  string t1 = convsub(s.substr(0, loc), numsec0);
  string t2 = convsub(s.substr(loc + 2), numsec1);
  if (t1.size() > 0) t1 += ":";
  for (int i = 0; i < 8 - numsec0 - numsec1; i++) {
    t1 += "0000";
    if (i != 8 - numsec0 - numsec1 - 1) t1 += ":";
  }
  if (t2.size() > 0) t1 += ":";
  t1 += t2;
  return t1;
}
int main(void) {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    cout << conv(s) << endl;
  }
  return 0;
}
