#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, empty, q, temp;
  string s, part, res;
  bool f;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s;
    if (s == "::") {
      cout << "0000:0000:0000:0000:0000:0000:0000:0000" << endl;
      continue;
    }
    part = "";
    res = "";
    empty = -1;
    q = 0;
    for (int j = 0; j < s.size(); j++) {
      part += s[j];
      if (s[j] == ':' || j == s.size() - 1) {
        temp = j == s.size() - 1 ? 1 : 0;
        q++;
        if (part == ":") {
          empty = q - 1;
          if (!temp) {
            res += part;
          }
          part = "";
          continue;
        }
        for (int k = part.size(); k <= 4 - temp; k++) {
          part = "0" + part;
        }
        res += part;
        part = "";
        continue;
      }
    }
    if (empty != -1) {
      if (s[0] == ':') {
        empty = 0;
        q--;
        res.erase(0, 1);
      }
      part = "";
      for (; q <= 8; q++) {
        part += "0000:";
      }
      part.pop_back();
      res = res.insert(empty * 5, part);
    }
    cout << res << endl;
  }
}
