#include <bits/stdc++.h>
using namespace std;
namespace IO {
const int MAXIOSIZE = 1 << 24 | 1;
unsigned char buf[MAXIOSIZE], *p1, *p2;
template <typename T>
void read(T& x) {
  x = 0;
  char ch = getchar();
  bool flg = false;
  for (; ch < '0' || '9' < ch; ch = getchar())
    if (ch == '-') flg |= true;
  for (; '0' <= ch && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
  flg ? x = -x : 0;
}
template <typename T>
void out(const T& x) {
  if (x > 9) out(x / 10);
  putchar(x % 10 + '0');
}
template <typename T>
inline void write(const T& x, const char& ed = ' ') {
  if (x < 0)
    putchar('-'), out(-x);
  else
    out(x);
  putchar(ed);
}
}  // namespace IO
string str;
void solve() {
  cin >> str;
  vector<string> handle;
  handle.push_back("");
  for (int idx = (0), idxend = (str.size()); idx < idxend; ++idx) {
    if (str[idx] == ':')
      handle.push_back("");
    else
      handle.back() += str[idx];
  }
  for (int idx = (1), idxend = (handle.size()); idx < idxend; ++idx) {
    if (handle[idx] == "" && (handle[idx - 1] == "" || idx == str.size() - 1)) {
      handle.erase(handle.begin() + idx - 1);
      break;
    }
  }
  for (string& str : handle) {
    if (str.size()) {
      reverse(str.begin(), str.end());
      while (str.size() < 4) str += "0";
      reverse(str.begin(), str.end());
    }
  }
  for (int idx = (0), idxend = (handle.size()); idx < idxend; ++idx) {
    if (handle[idx] == "") {
      while (handle.size() < 8) handle.insert(handle.begin() + idx, "");
    }
  }
  for (string& str : handle) {
    if (str == "") str = "0000";
  }
  for (int idx = (0), idxend = (handle.size()); idx < idxend; ++idx) {
    cout << handle[idx];
    if (idx < handle.size() - 1) cout << ":";
  }
  cout << '\n';
}
int main() {
  int t;
  IO::read(t);
  while (t--) solve();
  return 0;
}
