#include <bits/stdc++.h>
using namespace std;
int main() {
  int m, n, i, j, l, a[100];
  char c[100], b[100];
  while (scanf("%d", &n) != EOF) {
    while (n--) {
      scanf("%s", &c);
      l = strlen(c);
      m = 1;
      for (i = 1; i <= 32; i++) b[i] = '0';
      for (i = 0; i < l; i++)
        if (c[i] == ':') {
          a[m] = i;
          m++;
        }
      int z = 0;
      if (c[0] == ':' && c[1] == ':') z = m - 2;
      a[m] = l;
      l = 0;
      if (c[0] == ':')
        a[0] = 10000;
      else
        a[0] = -1;
      for (i = 1; i <= m; i++) {
        if (a[i] - a[i - 1] == 5) {
          for (j = 1; j <= 4; j++) b[j + l] = c[a[i - 1] + j];
          l = l + 4;
        } else if (a[i] - a[i - 1] > 1) {
          int k = a[i] - a[i - 1];
          int q = 5 - k;
          for (j = 1; j <= q; j++) b[j + l] = '0';
          for (j = q + 1; j <= 4; j++) b[j + l] = c[a[i - 1] + j - q];
          l = l + 4;
        } else if (a[i] - a[i - 1] == 1) {
          int s = 8 - m;
          s++;
          if (z != 0) s = 8 - z;
          while (s--) {
            for (j = 1; j <= 4; j++) b[j + l] = '0';
            l = l + 4;
          }
        }
      }
      for (i = 0; i < 8; i++) {
        for (j = 1; j <= 4; j++) printf("%c", b[i * 4 + j]);
        if (i < 7) printf(":");
      }
      printf("\n");
    }
  }
}
