#include <bits/stdc++.h>
using namespace std;
int n;
string input, s = "";
vector<string> v;
int main() {
  cin >> n;
  while (n--) {
    cin >> input;
    v.clear();
    s = "";
    for (int j = 0; j < input.size(); j++) {
      if (input[j] == ':') {
        if (j != 0) {
          v.push_back(s);
          s = "";
        }
      } else
        s += input[j];
    }
    if (s != "") v.push_back(s);
    for (int j = 0; j < v.size(); j++) {
      if (v[j] != "") {
        for (int k = 0; k < 4 - v[j].size(); k++) cout << 0;
        cout << v[j];
      } else
        for (int k = 0; k < 9 - v.size(); k++) {
          cout << "0000";
          if (k != 8 - v.size()) cout << ":";
        }
      if (j != v.size() - 1) cout << ":";
    }
    puts("");
  }
  return 0;
}
