#include <bits/stdc++.h>
using namespace std;
vector<string> cur;
int N;
void go(string s) {
  cur.clear();
  int loc = 0;
  while (loc < s.length()) {
    string c = "";
    while (loc < s.length() and s[loc] != ':') {
      c += s[loc];
      loc++;
    }
    loc++;
    if (loc == 1 and cur.size() == 0) continue;
    cur.push_back(c);
  }
  for (int i = 0; i < cur.size(); i++) {
    for (int j = cur[i].length(); j < 4; j++) cout << "0";
    cout << cur[i];
    if (cur[i].length() == 0) {
      for (int j = cur.size(); j < 8; j++) {
        cout << ":0000";
      }
    }
    if (i != cur.size() - 1) cout << ":";
  }
  cout << endl;
}
int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    go(s);
  }
}
