#include <bits/stdc++.h>
using namespace std;
char data[1000];
int n, len, pac;
void slove1() {
  int i, num = 0, j;
  char p[10];
  for (i = 0; i < len; i++) {
    if (data[i] == ':' || i == len - 1) {
      if (i == len - 1) p[num++] = data[i];
      int k = 4 - num;
      while (k--) printf("0");
      for (j = 0; j < num; j++) printf("%c", p[j]);
      if (i != len - 1) printf(":");
      num = 0;
    } else
      p[num++] = data[i];
  }
  puts("");
}
void slove2() {
  int number = 0, i, j, ca = 0;
  char p[100], ans2[100], answer[100];
  int num = 0;
  for (i = 0; i < pac; i++) {
    if (data[i] == ':' || i == pac - 1) {
      ca++;
      if (i == pac - 1) p[num++] = data[i];
      int k = 4 - num;
      while (k--) printf("0");
      for (j = 0; j < num; j++) printf("%c", p[j]);
      printf(":");
      num = 0;
    } else
      p[num++] = data[i];
  }
  num = 0;
  number = 0;
  bool sign = false;
  for (i = pac + 2; i < len; i++) {
    sign = true;
    if (data[i] == ':' || i == len - 1) {
      ca++;
      if (i == len - 1) p[num++] = data[i];
      int k = 4 - num;
      while (k--) ans2[number++] = '0';
      for (j = 0; j < num; j++) ans2[number++] = p[j];
      if (i != len - 1) ans2[number++] = ':';
      num = 0;
    } else
      p[num++] = data[i];
  }
  ans2[number] = '\0';
  ca = 8 - ca;
  if (sign) {
    while (ca--) printf("0000:");
    printf("%s", ans2);
  } else {
    while (ca--) {
      if (ca == 0)
        printf("0000");
      else
        printf("0000:");
    }
  }
  puts("");
}
int main() {
  int i;
  bool sign;
  scanf("%d", &n);
  while (n--) {
    sign = false;
    scanf("%s", data);
    len = strlen(data);
    for (i = 0; i < len - 1; i++)
      if (data[i] == ':' && data[i + 1] == ':') {
        pac = i;
        slove2();
        sign = true;
      }
    if (!sign) slove1();
  }
  return 0;
}
