#include <bits/stdc++.h>
const int maxn = 60;
char s[5] = {'0', '0', '0', '0', '\0'};
char st[maxn];
char str[10];
char G[10][10];
int num[10];
int main() {
  int n, len, i, sum, l, j, t, sumj, cc, cs;
  scanf("%d", &n);
  getchar();
  while (n--) {
    fgets(st, sizeof(st), stdin);
    len = strlen(st) - 1;
    sum = 0;
    t = 0;
    j = 1;
    for (i = 0; i < len; i++) {
      l = 0;
      while (st[i] != ':' && i < len) {
        G[j][l++] = st[i++];
      }
      if (l) {
        G[j][l] = '\0';
        num[j] = l;
        j++;
      } else {
        t = j;
      }
    }
    if (j == 1) {
      for (i = 1; i <= 8; i++) {
        if (i != 1) printf(":");
        printf("%s", s);
      }
      printf("\n");
    } else {
      cs = 1;
      sum = 8 - j + 1;
      sumj = j;
      j = 1;
      for (i = 1; i <= 8; i++) {
        if (i != t) {
          cc = 4 - num[j];
          while (cc--) printf("0");
          for (cc = 0; cc < num[j]; cc++) printf("%c", G[j][cc]);
          j++;
          if (cs++ < 8) printf(":");
        } else {
          while (sum--) {
            i++;
            printf("%s", s);
            if (cs++ < 8) printf(":");
          }
          i--;
        }
      }
      printf("\n");
    }
  }
  return 0;
}
