#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
int64_t lol;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cerr.tie(nullptr);
  int64_t testc = 1;
  cin >> testc;
  while (testc--) {
    string x;
    cin >> x;
    long long temp = 0;
    for (auto i : x) {
      if (i == ':') {
        ++temp;
      }
    }
    for (long long i = 0; i < x.length(); i++) {
      if (x[i] == ':') {
        if (x[i + 1] == ':') {
          while (temp < 7) {
            ++temp;
            x = x.substr(0, i + 1) + ":" + x.substr(i + 1, x.size() - i - 1);
          }
          while (temp > 7) {
            --temp;
            x = x.substr(0, i) + x.substr(i + 1, x.size() - i - 1);
          }
        }
      }
    }
    x.push_back(':');
    temp = 0;
    string out = "";
    for (long long i = 1; i <= x.length(); i++) {
      if (x[i - 1] == ':') {
        long long zz = (i - temp - 1);
        long long zzz = zz;
        zz = 4 - zz;
        while (zz--) {
          out += '0';
        }
        temp = i;
        for (long long ii = (i - zzz); ii < i; ii++) {
          out += x[ii - 1];
        }
        out += ":";
      }
    }
    out.pop_back();
    cout << out << "\n";
  }
  return EXIT_SUCCESS;
}
