#include <bits/stdc++.h>
using namespace std;
const int N = 11;
int main() {
  ios::sync_with_stdio(false);
  int T;
  cin >> T;
  while (T--) {
    string s;
    cin >> s;
    int len = (int)s.size();
    len = (int)s.size();
    int sum = 0;
    string is = "";
    for (int i = 0; i < len; i++)
      if (s[i] == ':') sum++;
    for (int i = 0; i < len; i++) {
      if ((i != len - 1) && s[i] == ':' && s[i + 1] == ':') {
        for (int j = 1; j <= 7 - sum; j++) is = is + ':';
        if (sum > 7) continue;
        sum = 7;
      }
      is = is + s[i];
    }
    int pre = 0;
    int calc = 0;
    int ilen = (int)is.size();
    for (int i = 0; i < ilen; i++)
      if (is[i] == ':') {
        for (int j = 1; j <= 4 - (i - pre); j++) {
          cout << 0;
          calc++;
        }
        for (int j = pre; j < i; j++) {
          cout << (char)is[j];
          calc++;
        }
        cout << ':';
        calc++;
        pre = i + 1;
      }
    if (calc > 35)
      for (;;)
        ;
    for (int j = 1; j <= 4 - (ilen - pre); j++) {
      cout << 0;
      calc++;
    }
    for (int j = pre; j < ilen; j++) {
      cout << (char)is[j];
      calc++;
    }
    cout << '\n';
  }
  return 0;
}
