#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
int main() {
  int cases;
  scanf("%d", &cases);
  while (cases--) {
    char str[1009];
    int ret[9];
    scanf("%s", str);
    int num = 0;
    int i;
    int cnt = 0;
    int flag = -1;
    for (i = 0; str[i]; i++) {
      if (str[i] >= 'A' && str[i] <= 'Z') {
        str[i] = str[i] - 'A' + 'a';
      }
      if (str[i] == ':') {
        if (str[i + 1] == ':') {
          flag = cnt;
          i++;
        }
        ret[cnt] = num;
        cnt++;
        num = 0;
      } else if (str[i] >= '0' && str[i] <= '9') {
        num = num * 16 + str[i] - '0';
      } else {
        num = num * 16 + str[i] - 'a' + 10;
      }
    }
    ret[cnt++] = num;
    int k = 0;
    for (int j = 0; j < cnt; j++) {
      printf("%04x", ret[j]);
      k++;
      if (k != 8) {
        putchar(':');
      }
      if (flag == j) {
        for (i = 0; i < 8 - cnt; i++) {
          printf("0000");
          k++;
          if (k != 8) {
            putchar(':');
          }
        }
      }
    }
    putchar(10);
  }
  return 0;
}
