#include <bits/stdc++.h>
using namespace std;
int n, cnt, len;
char s[1100], t[1100];
void rcd(int l, int r) {
  if (l >= len) return;
  int i, k;
  for (i = l, k = 0; i <= r; i++)
    if (s[i] != ':') k++;
  k = 4 - k;
  for (i = 0; i < k; i++) t[cnt++] = '0';
  for (i = l; i <= r; i++) t[cnt++] = s[i];
}
void trans() {
  int i, j, com, lft = 0, rgt = 0, lst;
  len = strlen(s);
  cnt = 0;
  for (i = 0; i < len; i++)
    if (s[i] == s[i + 1] && s[i] == ':') break;
  if (i < len) {
    for (j = 0, lst = 0; j < i; j++)
      if (s[j] == ':') {
        rcd(lst, j);
        lst = j + 1;
        lft++;
      }
    rcd(lst, i);
    lft++;
    if (i + 1 == len - 1) {
      com = 8 - lft;
      for (j = 0; j < com; j++) {
        for (int k = 0; k < 4; k++) t[cnt++] = '0';
        t[cnt++] = ':';
      }
      t[cnt - 1] = 0;
      return;
    }
    for (j = i + 1; j < len; j++)
      if (s[j] == ':') rgt++;
    com = 8 - lft - rgt;
    for (j = 0; j < com; j++) {
      for (int k = 0; k < 4; k++) t[cnt++] = '0';
      t[cnt++] = ':';
    }
    for (j = i + 2, lst = i + 2; j < len; j++)
      if (s[j] == ':') {
        rcd(lst, j);
        lst = j + 1;
      }
    rcd(lst, len - 1);
    t[cnt] = 0;
  } else {
    for (j = 0, lst = 0; j < len; j++)
      if (s[j] == ':') {
        rcd(lst, j);
        lst = j + 1;
      }
    rcd(lst, len - 1);
    t[cnt] = 0;
  }
}
int main() {
  int i;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%s", s);
    trans();
    printf("%s\n", t);
  }
  return 0;
}
