#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const long long SIZE = 1e5 + 5;
const long long mod = 1e9 + 7;
int main() {
  long long t = 0, n, x, y, z, i, j, k, g, p, q, ans = 0, sum = 0, c = 0;
  string s, s1, s2;
  scanf("%lld", &q);
  while (q--) {
    cin >> s;
    n = s.size();
    t = 0;
    c = 0;
    p = 0;
    for (i = 0; i < n; i++) {
      if (s[i] != ':') {
        t++;
        j = i;
        while (s[j] != ':' && j < n) j++;
        i = j - 1;
      } else {
        if (s[i + 1] == ':') c = i + 1;
      }
    }
    if (c) t = 8 - t;
    for (i = 0; i < n; i++) {
      if (s[i] != ':') {
        j = i;
        x = 0;
        while (s[j] != ':' && j < n) {
          x++;
          j++;
        }
        for (y = 1; y <= 4 - x; y++) cout << 0;
        for (y = i; y < j; y++) cout << s[y];
        p++;
        i = j - 1;
      } else {
        if (s[i + 1] == ':' && i + 1 == 1) {
          for (x = 1; x <= t; x++) {
            cout << "0000";
            p++;
            if (p != 8) cout << ":";
          }
          i++;
          continue;
        }
        cout << s[i];
        if (s[i + 1] == ':') {
          for (x = 1; x <= t; x++) {
            cout << "0000";
            p++;
            if (p != 8) cout << ":";
          }
          i++;
        }
      }
    }
    printf("\n");
  }
  return 0;
}
