#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int pz = -1;
    vector<string> sl;
    string a;
    cin >> a;
    unsigned j = 0;
    while (j < a.size()) {
      string b;
      while (j < a.size() && isalnum(a[j])) {
        b.push_back(a[j]);
        j++;
      }
      string ax;
      for (int t = 1; t <= 4 - b.size(); t++) ax.push_back('0');
      ax += b;
      ax += ":";
      sl.push_back(ax);
      if (j == a.size()) break;
      if (a[j + 1] == ':') {
        j++;
        pz = sl.size() - 1;
      }
      j++;
    }
    for (unsigned j = 0; j < sl.size(); j++) {
      if (pz != sl.size() - 1 && j == sl.size() - 1)
        for (unsigned t = 0; t < sl[j].size() - 1; t++) cout << sl[j][t];
      else
        cout << sl[j];
      if (j == pz) {
        int ex = 0;
        if (pz == sl.size() - 1) ex = 1;
        for (int t = 0; t < 8 - sl.size() - ex; t++) cout << "0000:";
        if (ex) cout << "0000";
      }
    }
    cout << '\n';
  }
  return 0;
}
