#include <bits/stdc++.h>
int t, n, cnt, son, next[1005];
char s[1005];
int main() {
  scanf("%d", &t);
  while (t--) {
    scanf("%s", s), n = strlen(s), cnt = 0, son = n;
    for (int i = n - 1; i >= 0; i--)
      if (s[i] == ':') cnt++, next[i] = son, son = i;
    for (int i = son; i < 4; i++) printf("0");
    for (int i = 0; i < n; i++)
      if (s[i] == ':')
        if (s[i + 1] == ':')
          while (++cnt <= 8) printf(":0000");
        else {
          printf(":");
          for (int j = next[i] - i; j <= 4; j++) printf("0");
        }
      else
        printf("%c", s[i]);
    puts("");
  }
  return 0;
}
