#include <bits/stdc++.h>
using namespace std;
int fin(char s[]) {
  int t = 0;
  for (int i = 0; s[i]; i++) {
    if (s[i] == ':') t++;
  }
  return 7 - t;
}
void out(char *p) {
  if (*(p + 1) == ':') {
    cout << "0000";
  } else if (*(p + 1) == 0) {
    cout << "0000";
  } else if (*(p + 2) == 0) {
    cout << "000" << *(p + 1);
    p += 2;
  } else if (*(p + 3) == 0) {
    cout << "00" << *(p + 1) << *(p + 2);
    p += 3;
  } else if (*(p + 4) == 0) {
    cout << '0' << *(p + 1) << *(p + 2) << *(p + 3);
    p += 4;
  } else {
    cout << *(p + 1) << *(p + 2) << *(p + 3) << *(p + 4);
    p += 5;
  }
  cout << endl;
}
int main() {
  int n, a;
  cin >> n;
  char s[11111];
  while (n--) {
    memset(s, 0, sizeof(s));
    cin >> s;
    if (s[0] == ':' && s[1] == ':' && s[2] == 0)
      cout << "0000:0000:0000:0000:0000:0000:0000:0000" << endl;
    else {
      int t = fin(s);
      char *p = s;
      if (*p != ':' || (*p == ':' && t >= 0)) p--;
      int q = 0;
      while (q < 7) {
        q++;
        if (*(p + 1) == ':') {
          cout << "0000:";
          while (t > 0) {
            t--;
            q++;
            cout << "0000:";
          }
          p += 1;
        } else if (*(p + 2) == ':') {
          cout << "000" << *(p + 1) << ':';
          p += 2;
        } else if (*(p + 3) == ':') {
          cout << "00" << *(p + 1) << *(p + 2) << ':';
          p += 3;
        } else if (*(p + 4) == ':') {
          cout << '0' << *(p + 1) << *(p + 2) << *(p + 3) << ':';
          p += 4;
        } else {
          cout << *(p + 1) << *(p + 2) << *(p + 3) << *(p + 4) << ':';
          p += 5;
        }
      }
      out(p);
    }
  }
  return 0;
}
