#include <bits/stdc++.h>
using namespace std;
string process(string s) {
  int p = -1, c = 0;
  if (s.find("::") != string::npos) {
    for (int i = 0, _a = (int(s.size())); i < _a; ++i)
      if (s[i] == ':') {
        if (i - p > 1) c++;
        p = i;
      }
    if (p < int(s.size()) - 1) c++;
    string st = "";
    for (int i = 0, _a = (8 - c); i < _a; ++i) {
      st += ':';
      for (int j = 0, _a = (4); j < _a; ++j) st += '0';
    }
    st += ':';
    s.replace(s.find("::"), 2, st);
    if (s[0] == ':') s.erase(0, 1);
    if (s[int(s.size()) - 1] == ':') s.erase(int(s.size()) - 1, 1);
  }
  p = int(s.size());
  for (int i = (int(s.size())) - 1; i >= 0; --i)
    if (s[i] == ':') {
      for (int j = 0, _a = (5 - (p - i)); j < _a; ++j) s.insert(i + 1, "0");
      p = i;
    }
  for (int j = 0, _a = (4 - p); j < _a; ++j) s.insert(0, "0");
  return s;
}
int main() {
  int n;
  string s;
  cin >> n;
  for (int i = 0, _a = (n); i < _a; ++i) {
    cin >> s;
    cout << process(s) << endl;
  }
  return 0;
}
