#include <bits/stdc++.h>
using namespace std;
const int INF = 2147483647;
const long long LLINF = 9223372036854775807LL;
int get(char c) {
  if (c >= '0' && c <= '9') return c - '0';
  return 10 + c - 'a';
}
vector<int> conv(string s) {
  vector<int> v;
  int cur = 0;
  for (int i = 0; i < int((s).size()); ++i) {
    if (s[i] != ':') cur = cur * 16 + get(s[i]);
    if (i == int((s).size()) - 1 || s[i + 1] == ':') v.push_back(cur), cur = 0;
    if (s[i] == ':') {
      if (s[i + 1] == ':') {
        v.push_back(-1);
        ++i;
      }
    }
  }
  vector<int> rem(8 - int((v).size()) + 1, 0);
  for (int i = 0; i < int((v).size()); ++i) {
    if (v[i] == -1)
      v.erase(v.begin() + i), v.insert(v.begin() + i, rem.begin(), rem.end());
  }
  return v;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    vector<int> v = conv(s);
    assert(int((v).size()) == 8);
    for (int i = 0; i < int((v).size()); ++i) {
      if (i) printf(":");
      printf("%04x", v[i]);
    }
    printf("\n");
  }
  return 0;
}
