#include <bits/stdc++.h>
using namespace std;
char a[10][203];
char b[203];
int n;
int main() {
  scanf("%d", &n);
  int i, j, ii, jj;
  int temp;
  int coun, coun2;
  for (i = 0; i < n; i++) {
    scanf("%s", b);
    coun = 0;
    j = 0;
    while (b[j]) {
      if (j == 0 && b[j] != ':') {
        coun2 = 0;
        while (b[j] != ':' && b[j]) j++;
        temp = j;
        jj = temp - 1;
        while (b[jj] != ':' && jj > -1) {
          a[coun][3 - coun2++] = b[jj];
          jj--;
        }
        while (coun2 < 4) a[coun][3 - coun2++] = '0';
        j = temp;
        coun++;
      } else if (b[j] == ':') {
        if (b[j + 1] == ':') {
          for (jj = 0; jj < 4; jj++) a[coun][jj] = '0';
          coun2 = 0;
          for (jj = j + 1; b[jj]; jj++)
            if (b[jj] == ':' && b[jj + 1] != '\0') coun2++;
          temp = coun;
          for (ii = 1; ii <= 8 - temp - 1 - coun2; ii++) {
            coun++;
            for (jj = 0; jj < 4; jj++) a[coun][jj] = '0';
          }
          j = j + 1;
          coun++;
          if (!b[j + 1]) j++;
        } else {
          j++;
          coun2 = 0;
          while (b[j] != ':' && b[j]) j++;
          temp = j;
          jj = temp - 1;
          while (b[jj] != ':' && jj > -1) {
            a[coun][3 - coun2++] = b[jj];
            jj--;
          }
          while (coun2 < 4) a[coun][3 - coun2++] = '0';
          j = temp;
          coun++;
        }
      }
    }
    for (j = 0; j < 8; j++) {
      if (j != 0) printf(":");
      for (jj = 0; jj < 4; jj++) printf("%c", a[j][jj]);
    }
    printf("\n");
    for (j = 0; b[j]; j++) b[j] = '\0';
  }
  return 0;
}
