#include <bits/stdc++.h>
using namespace std;
int main() {
  string str, ans, s, str1, str2;
  int n, p, sum, i;
  cin >> n;
  while (n--) {
    cin >> str;
    ans = "";
    sum = 0;
    p = str.find("::");
    if (p != string::npos) {
      for (i = 0; i < str.length(); i++) {
        if (str[i] == ':') sum++;
      }
      str1 = str.substr(0, p + 1);
      str2 = str.substr(p + 2);
      s = "";
      for (i = 0; i <= 7 - sum; i++) {
        s += "000:";
      }
      str = str1 + s + str2;
    }
    for (;;) {
      p = str.find_first_of(':');
      if (p == string::npos) {
        s = str.substr(0);
        str = str.substr(p + 1);
        s = string(4 - s.length(), '0') + s;
        ans = ans + s + ":";
        break;
      }
      s = str.substr(0, p);
      str = str.substr(p + 1);
      s = string(4 - s.length(), '0') + s;
      ans = ans + s + ":";
    }
    for (; ans.length() < 39;) {
      ans += "0000:";
    }
    ans = ans.substr(0, ans.length() - 1);
    cout << ans << endl;
  }
}
