#include <bits/stdc++.h>
using namespace std;
int n;
char s[50], ss[50], ans[50];
int main() {
  int i, j, k, l, t, cas;
  scanf("%d", &n);
  gets(s);
  for (cas = 0; cas < n; cas++) {
    memset(s, 0, sizeof(s));
    memset(ss, 0, sizeof(ss));
    memset(ans, 0, sizeof(ans));
    j = 0;
    gets(s);
    l = strlen(s);
    for (i = 0; i < l; i++)
      if (s[i] == ':') {
        j++;
        while (s[++i] == ':')
          ;
      }
    if (s[l - 1] == ':') j--;
    if (s[0] == ':') j--;
    k = 0;
    for (i = 0; i < l; i++)
      if (s[i] == ':' && s[i + 1] == ':') {
        for (t = 0; t < 7 - j; t++) {
          if (k) ss[k++] = ':';
          ss[k++] = '0';
        }
        if (i != l - 2) ss[k++] = ':';
        i++;
      } else
        ss[k++] = s[i];
    ss[k++] = ':';
    ss[k] = 0;
    l = k;
    k = 0;
    while (ss[++k] != ':')
      ;
    for (i = 0; i < 4 - k; i++) ans[i] = '0';
    for (i = 4 - k; i < 4; i++) ans[i] = ss[i - 4 + k];
    ans[4] = ':';
    i = k + 1;
    k = 5;
    for (; i < l - 1; i++) {
      j = i - 1;
      while (ss[++j] != ':')
        ;
      {
        for (t = 0; t < 4 - j + i; t++) ans[k++] = '0';
        for (t = i; t <= j; t++) ans[k++] = ss[t];
      }
      i = j;
    }
    ans[k - 1] = 0;
    puts(ans);
  }
  return 0;
}
