#include <bits/stdc++.h>
using namespace std;
void solve() {
  char S[105];
  scanf("%s", S);
  char *q = strstr(S, "::");
  vector<int> A, B;
  for (char *p = strtok(S, ":"); p; p = strtok(NULL, ":")) {
    int val;
    sscanf(p, "%x", &val);
    if (p < q)
      A.push_back(val);
    else
      B.push_back(val);
  }
  A.insert(A.end(), 8 - A.size() - B.size(), 0);
  A.insert(A.end(), B.begin(), B.end());
  for (int i = 0; i < 7; ++i) printf("%04x:", A[i]);
  printf("%04x\n", A[7]);
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) solve();
  return 0;
}
