#include <bits/stdc++.h>
using std::cerr;
using std::cin;
using std::clock;
using std::cos;
using std::cout;
using std::endl;
using std::make_pair;
using std::map;
using std::max;
using std::min;
using std::next_permutation;
using std::nth_element;
using std::pair;
using std::priority_queue;
using std::queue;
using std::random_shuffle;
using std::set;
using std::sin;
using std::sort;
using std::sqrt;
using std::stack;
using std::string;
using std::stringstream;
using std::swap;
using std::vector;
const long double PI = 3.14159265358979323846;
const long double gammama = 0.57721566490153286060;
const long double eps = 1e-13;
string restore(string s) {
  string res = "";
  string t = "";
  vector<string> da;
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] != ':')
      t += s[i];
    else {
      if ((i == 1) && (s[i - 1] == ':')) continue;
      da.push_back(t);
      t = "";
    }
  }
  if (!t.empty()) da.push_back(t);
  int n = da.size();
  for (int i = 0; i < da.size(); ++i) {
    if (da[i].empty()) {
      for (int k = n; k < 9; ++k) {
        res += "0000:";
      }
      continue;
    }
    while (da[i].size() < 4) da[i] = '0' + da[i];
    res += da[i] + ":";
  }
  res.resize(res.size() - 1);
  return res;
}
int main() {
  int n;
  cin >> n;
  string s;
  for (int i = 0; i < n; ++i) {
    cin >> s;
    cout << restore(s) << endl;
  }
  return 0;
}
