#include <bits/stdc++.h>
using namespace std;
int main() {
  size_t found;
  vector<string> str;
  string a, b, c, in, out;
  long long i, j, k, m, n, l, t;
  cin >> t;
  while (t--) {
    cin >> in;
    for (i = 0, j = 0, k = 0; i < in.size(); i++) {
      if (in[i] == ':' && i == 0) {
        i++;
        j = 1;
      }
      if (in[i] == ':') {
        b = in.substr(j, i - j);
        if (b == "") k++;
        str.push_back(b);
        j = i + 1;
      }
    }
    if (in[in.size() - 1] != ':') {
      b = in.substr(j, in.size() - j);
      str.push_back(b);
    }
    for (i = 0; i < str.size(); i++) {
      if (i > 0) cout << ":";
      if (str[i] == "") {
        for (j = 0; j < 8 - str.size() + k; j++) {
          if (j > 0) cout << ":";
          cout << "0000";
        }
      } else {
        if (str[i].size() < 4) {
          for (l = str[i].size(); l < 4; l++) cout << "0";
        }
        cout << str[i];
      }
    }
    cout << endl;
    str.clear();
    in.clear();
    k = 0;
  }
  return 0;
}
