#include <bits/stdc++.h>
using namespace std;
int q, a[2000];
char second[20000];
int main() {
  scanf("%d\n", &q);
  while (q--) {
    gets(second);
    int n = strlen(second);
    int k = 0;
    int ok = 0;
    for (int i = 0; i < n; ++i)
      if (second[i] == ':') a[++k] = i;
    int pn = -1;
    for (int i = 1; i < k; ++i) {
      if (a[i + 1] - a[i] == 1) pn = i;
    }
    if (pn == -1) {
      a[0] = -1;
      a[++k] = n;
      for (int i = 0; i < k; ++i) {
        for (int j = 0; j < 5 + a[i] - a[i + 1]; ++j) putchar('0');
        for (int j = a[i] + 1; j < a[i + 1]; ++j) putchar(second[j]);
        if (i + 1 < k) putchar(':');
      }
    } else {
      a[0] = -1;
      a[++k] = n;
      for (int i = 0; i < k; ++i) {
        if (i > 0 && i + 1 < k && a[i] + 1 == a[i + 1]) {
          for (int j = 0; j < 9 - k; ++j) {
            printf("0000");
            if (i + 1 < k) putchar(':');
          }
          continue;
        }
        for (int j = 0; j < 5 + a[i] - a[i + 1]; ++j) putchar('0');
        for (int j = a[i] + 1; j < a[i + 1]; ++j) putchar(second[j]);
        if (i + 1 < k) putchar(':');
      }
    }
    puts("");
  }
  return 0;
}
