#include <bits/stdc++.h>
using namespace std;
int n, k, t;
string a, s, temp;
int main() {
  cin >> n;
  for (int cass = 1; cass <= n; cass++) {
    a = "";
    t = k = 0;
    cin >> s;
    for (int i = 0; i < (int)s.size(); i++)
      if (s[i] == ':') t++;
    for (int i = 0; i < (int)s.size(); i++) {
      if (s[i] == ':') {
        temp = "";
        for (int j = (int)a.size(); j < 4; j++) temp += '0';
        temp += a;
        cout << temp << ":";
        a = "";
        if (i + 1 < (int)s.size() && s[i + 1] == ':') {
          for (int j = t; j <= 7; j++) {
            cout << "0000:";
          }
          i++;
        }
      } else
        a += s[i];
    }
    temp = "";
    for (int j = (int)a.size(); j < 4; j++) temp += '0';
    temp += a;
    cout << temp;
    cout << endl;
  }
  return 0;
}
