#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const double EPS = 1e-9;
const double PI = acos(-1.);
char buff[100500];
void solve() {
  scanf("%s", buff);
  int len = strlen(buff);
  vector<int> a[2];
  int cur = 0;
  int pos = 0;
  while (pos < len) {
    if (buff[pos] == ':' && buff[pos + 1] == ':') ++cur;
    while (buff[pos] == ':') ++pos;
    if (pos >= len) break;
    int t;
    sscanf(buff + pos, "%x", &t);
    a[cur].push_back(t);
    while (pos < len && buff[pos] != ':') ++pos;
  }
  int cnt = 8 - a[0].size() - a[1].size();
  for (int i = 0; i < cnt; ++i) a[0].push_back(0);
  for (int i = 0; i < a[1].size(); ++i) a[0].push_back(a[1][i]);
  printf("%04x", a[0][0]);
  for (int i = 1; i < 8; ++i) printf(":%04x", a[0][i]);
  puts("");
}
int main() {
  int T;
  scanf("%d", &T);
  for (int i = 0; i < T; ++i) solve();
  return 0;
}
