#include <bits/stdc++.h>
using namespace std;
int blocks[101], top = 0;
int main() {
  int n;
  cin >> n;
  getchar();
  while (n--) {
    int prev = 0;
    top = 0;
    while (1) {
      char c;
      while ((c = getchar()) && (c >= '0' && c <= '9' || c >= 'a' && c <= 'f'))
        prev = prev * 16 + (c <= '9' ? (c - '0') : (c - 'a' + 10));
      blocks[top++] = prev;
      prev = 0;
      if (c != ':') break;
      c = getchar();
      if (c == ':')
        blocks[top++] = -1;
      else
        prev = (c <= '9' ? (c - '0') : (c - 'a' + 10));
    }
    for (int i = 0, sa = 0; i < top; ++i)
      if (blocks[i] != -1)
        printf("%s%04x", sa ? ":" : "", blocks[i]), sa = 1;
      else
        for (int j = 0; j <= 8 - top; ++j)
          printf("%s0000", sa ? ":" : ""), sa = 1;
    printf("\n");
  }
  return 0;
}
