#include <bits/stdc++.h>
using namespace std;
string mkstr(string s) {
  int l = s.size();
  for (int i = 0; i < 4 - l; i++) s = '0' + s;
  return s;
}
void solve() {
  vector<string> v;
  char ar[100], mn[100];
  scanf(" %[^\n]", ar);
  strcpy(mn, ar);
  char *token = strtok(ar, ":\0");
  string s;
  while (token != NULL) {
    v.push_back(token);
    token = strtok(NULL, ":\0");
  }
  int bl = 0;
  if (v.size() != 8)
    for (int i = 0; mn[i + 1]; i++) {
      if (mn[i] == ':') {
        bl++;
        if (mn[i + 1] == ':') break;
      }
    }
  if (ar[0] == ':' and ar[1] == ':') bl = 0;
  int count = 0;
  for (int i = 0; i < bl; i++) cout << mkstr(v[i]) << ":\n"[++count == 8];
  for (int i = 0; i < 8 - v.size(); i++)
    cout << "0000"
         << ":\n"[++count == 8];
  for (int i = bl; i < v.size(); i++)
    cout << mkstr(v[i]) << ":\n"[++count == 8];
  return;
}
int main() {
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}
