#include <bits/stdc++.h>
using namespace std;
template <class T>
T gcd(T a, T b) {
  return (b == 0) ? a : gcd(b, a % b);
}
template <class T>
T lcm(T a, T b) {
  return a * (b / gcd(a, b));
}
string solve(string S) {
  if (S == "::") return "0000:0000:0000:0000:0000:0000:0000:0000";
  string ans;
  int len = S.length();
  for (int i = (0); i < (len); ++i) {
    if (S[i] == ':') {
      ans.push_back(':');
      continue;
    }
    string temp;
    int j = i;
    for (; j < len; j++) {
      if (S[j] != ':')
        temp.push_back(S[j]);
      else
        break;
    }
    while (temp.length() < 4) temp = "0" + temp;
    ans += temp;
    if (j != len) ans.push_back(S[j]);
    i = j;
  }
  int LEN = ans.length();
  if (LEN == 39) return ans;
  if (ans[LEN - 1] == ':' && ans[LEN - 2] == ':') {
    ans.erase(LEN - 2, 2);
    while (ans.length() < 39) ans += ":0000";
    return ans;
  }
  if (ans.substr(0, 2) == "::") {
    ans.erase(0, 2);
    while (ans.length() < 39) ans = "0000:" + ans;
    return ans;
  }
  string ans1;
  string ans2;
  string temp1;
  for (int i = (0); i < (LEN); ++i) {
    if (ans[i] == ':' && ans[i + 1] == ':') {
      ans1 = ans.substr(0, i);
      ans2 = ans.substr(i + 1, LEN - i - 1);
      ans.erase(i, 2);
      while (ans.length() < 38) {
        ans += ":0000";
        temp1 += ":0000";
      }
    }
  }
  return ans1 + temp1 + ans2;
}
int main() {
  int T, ts = 0;
  cin >> T;
  while (T--) {
    string S;
    cin >> S;
    cout << solve(S) << endl;
  }
  return 0;
}
