#include <bits/stdc++.h>
using namespace std;
int main(int argc, char *argv[]) {
  int n;
  cin >> n;
  while (n--) {
    string s;
    cin >> s;
    stringstream ss(s);
    vector<string> sections;
    string str;
    while (getline(ss, str, ':')) {
      sections.push_back(str);
    }
    if (sections.front() == "") sections.erase(sections.begin());
    if (sections.size() < 8) {
      int count = 0, cur;
      for (int i = 0; i < sections.size(); i++) {
        if (sections[i] == "") cur = i;
      }
      while (sections.size() < 8) {
        sections.insert(sections.begin() + cur, "0000");
      }
    }
    for (int i = 0; i < sections.size(); i++) {
      string r = sections[i];
      if (r.size() < 4) {
        string z = "";
        for (int i = 0; i < 4 - r.size(); i++) z += "0";
        sections[i] = z + sections[i];
      }
    }
    for (int i = 0; i < sections.size() - 1; i++) {
      cout << sections[i] << ":";
    }
    cout << sections[7] << "\n";
  }
}
