#include <bits/stdc++.h>
using namespace std;
const int MAX = 1000 + 10;
int T;
char str[MAX];
char ans[100][MAX], answer[MAX];
int Main() {
  scanf("%s", str + 1);
  int len = strlen(str + 1), i;
  int top = 0;
  for (i = 1; i <= len;) {
    if (i + 1 <= len && str[i] == ':' && str[i + 1] == ':') {
      top++;
      ans[top][0] = -1;
      ++i;
      ++i;
      continue;
    }
    if (str[i] == ':') {
      ++i;
      continue;
    }
    top++;
    ans[top][0] = 0;
    while (i <= len && str[i] != ':') {
      ans[top][++ans[top][0]] = str[i];
      ++i;
    }
  }
  answer[0] = 0;
  for (i = 1; i <= top; ++i) {
    if (ans[i][0] == -1) {
      int p = 8 - top + 1;
      while (p--) {
        answer[++answer[0]] = '0';
        answer[++answer[0]] = '0';
        answer[++answer[0]] = '0';
        answer[++answer[0]] = '0';
        answer[++answer[0]] = ':';
      }
      continue;
    }
    for (int j = 1; j <= 4 - ans[i][0]; ++j) answer[++answer[0]] = '0';
    for (int j = 1; j <= ans[i][0]; ++j) answer[++answer[0]] = ans[i][j];
    answer[++answer[0]] = ':';
  }
  for (i = 1; i < answer[0]; ++i) printf("%c", answer[i]);
  printf("\n");
  return 0;
}
int main() {
  scanf("%d", &T);
  while (T--) Main();
  return 0;
}
