#include <bits/stdc++.h>
using namespace std;
const double eps = 1.0e-11;
const double pi = acos(-1.0);
void Process(string s) {
  vector<string> vs;
  string buf = "";
  for (long long i = 0; i < (int)(s).size(); i++) {
    if (s[i] == ':') {
      if (i && s[i - 1] == ':') {
        vs.push_back("x");
        continue;
      }
      while (buf.size() < 4) buf = "0" + buf;
      vs.push_back(buf);
      buf = "";
    } else {
      buf.push_back(s[i]);
    }
  }
  if (buf.size()) {
    while (buf.size() < 4) buf = "0" + buf;
    vs.push_back(buf);
  }
  for (long long i = 0; i < (int)(vs).size(); i++) {
    if (vs[i] == "x") {
      while (vs.size() < 9) vs.insert(vs.begin() + i + 1, "0000");
      vs.erase(vs.begin() + i);
    }
  }
  for (long long i = 0; i < (int)(vs).size(); i++) {
    if (i) cout << ":";
    cout << vs[i];
  }
  cout << endl;
}
int main() {
  int n;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    string tmp;
    cin >> tmp;
    Process(tmp);
  }
  return 0;
}
