#include <bits/stdc++.h>
using namespace std;
char str[100], ans[100];
int main() {
  int n, i, t, k, now, l, last, tt;
  scanf("%d", &n);
  for (tt = 1; tt <= n; tt++) {
    int flag = 0;
    for (i = 1; i <= 40; i++) ans[i] = '0';
    scanf("%s", str + 1);
    l = strlen(str + 1);
    last = 0;
    str[0] = '.';
    str[l + 1] = '.';
    k = 0;
    for (i = 1; i <= l; i++) {
      if (str[i] == ':' && str[i - 1] == ':') break;
      if (str[i] == ':') {
        now = i - last - 1;
        last = i;
        if (now == 0)
          k += 4;
        else if (now == 1) {
          k += 3;
          ans[++k] = str[i - 1];
        } else if (now == 2) {
          k += 2;
          ans[++k] = str[i - 2];
          ans[++k] = str[i - 1];
        } else if (now == 3) {
          k++;
          ans[++k] = str[i - 3];
          ans[++k] = str[i - 2];
          ans[++k] = str[i - 1];
        } else {
          ans[++k] = str[i - 4];
          ans[++k] = str[i - 3];
          ans[++k] = str[i - 2];
          ans[++k] = str[i - 1];
        }
        k++;
      }
    }
    if (i > l) {
      now = i - last - 1;
      for (i = 1; i <= now; i++) ans[40 - i] = str[l - i + 1];
      flag = 1;
    }
    last = l + 1;
    t = 40;
    if (flag == 0) {
      for (i = l; i >= 1; i--) {
        if (str[i] == ':' && str[i + 1] == ':') break;
        if (str[i] == ':') {
          now = last - i - 1;
          last = i;
          if (now == 0)
            t -= 4;
          else if (now == 1) {
            ans[--t] = str[i + 1];
            t -= 3;
          } else if (now == 2) {
            ans[--t] = str[i + 2];
            ans[--t] = str[i + 1];
            t -= 2;
          } else if (now == 3) {
            ans[--t] = str[i + 3];
            ans[--t] = str[i + 2];
            ans[--t] = str[i + 1];
            t--;
          } else {
            ans[--t] = str[i + 4];
            ans[--t] = str[i + 3];
            ans[--t] = str[i + 2];
            ans[--t] = str[i + 1];
          }
          t--;
        }
      }
    }
    for (i = 5; i <= 40; i += 5) ans[i] = ':';
    for (i = 1; i <= 39; i++) printf("%c", ans[i]);
    printf("\n");
  }
  return 0;
}
