#include <bits/stdc++.h>
using namespace std;
template <class T>
T abs(T x) {
  return x > 0 ? x : -x;
}
int n;
int m;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    string s, t;
    cin >> s;
    vector<string> v, w, u;
    for (int j = 0; j < ((int)(s).size()); j++)
      if (s[j] == ':') s[j] = ' ';
    for (int j = 0; j + 1 < ((int)(s).size()); j++)
      if (s[j] == ' ' && s[j + 1] == ' ') {
        stringstream in(s.substr(0, j));
        while (in >> t) v.push_back(t);
        stringstream in2(s.substr(j, ((int)(s).size()) - j));
        while (in2 >> t) w.push_back(t);
        for (int k = 0; k < 8 - ((int)(v).size()) - ((int)(w).size()); k++)
          u.push_back("");
        for (int k = 0; k < ((int)(u).size()); k++) v.push_back(u[k]);
        for (int k = 0; k < ((int)(w).size()); k++) v.push_back(w[k]);
        break;
      }
    if (((int)(v).size()) == 0) {
      stringstream in(s);
      while (in >> t) v.push_back(t);
    }
    for (int j = 0; j < ((int)(v).size()); j++)
      while (((int)(v[j]).size()) < 4) v[j] = "0" + v[j];
    for (int j = 0; j < ((int)(v).size()); j++) {
      if (j > 0) cout << ":";
      cout << v[j];
    }
    cout << endl;
  }
  return 0;
}
