#include <bits/stdc++.h>
using namespace std;
char A[105][55];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%s", A[i] + 1);
    int m = strlen(A[i] + 1), t = 0;
    char B[10];
    int tmp = 0, z = 0;
    for (int j = 1; j <= m; j++)
      if (A[i][j] == ':') tmp++;
    for (int j = 1; j <= m; j++) {
      if (A[i][j] != ':')
        B[++t] = A[i][j];
      else if (A[i][j] == ':') {
        if (A[i][j + 1] == ':') {
          if (z != 0) printf(":");
          for (int k = 1; k <= 4 - t; k++) printf("0");
          for (int k = 1; k <= t; k++) printf("%c", B[k]);
          z++;
          for (int k = 1; k <= 8 - tmp; k++) {
            if (z != 0) printf(":");
            printf("0000");
            z++;
          }
          j++;
        } else {
          if (z != 0) printf(":");
          for (int k = 1; k <= 4 - t; k++) printf("0");
          for (int k = 1; k <= t; k++) printf("%c", B[k]);
          z++;
        }
        t = 0;
      }
    }
    printf(":");
    for (int j = 1; j <= 4 - t; j++) printf("0");
    for (int j = 1; j <= t; j++) printf("%c", B[j]);
    printf("\n");
  }
  return 0;
}
