#include <bits/stdc++.h>
void logic(char *p) {
  int size = strlen(p);
  int i, j, pos = 0, len = 0, ct = 0;
  for (i = 0; i < size; i++)
    if (p[i] == ':') {
      if (i != 0 && p[i] == p[i - 1]) {
        ct = len / 5;
        for (j = i; j < size - 1; j++)
          if (p[j] == ':') ct++;
        for (j = ct; j <= 7; j++) {
          printf("0000");
          if (len < 35) {
            printf(":");
            len += 5;
          } else
            len += 4;
        }
        pos = i + 1;
      } else {
        for (j = i - pos; j < 4; j++) printf("0");
        for (j = pos; j < i; j++) printf("%c", p[j]);
        printf(":");
        pos = i + 1;
        len += 5;
      }
    } else if (i == size - 1) {
      for (j = i - pos + 1; j < 4; j++) printf("0");
      for (j = pos; j <= i; j++) printf("%c", p[j]);
    }
}
int main() {
  int i, num;
  char p[41];
  scanf("%d", &num);
  for (i = 0; i < num; i++) {
    scanf("%s", p);
    logic(p);
    printf("\n");
  }
  return 0;
}
