#include <bits/stdc++.h>
using namespace std;
int n;
string s;
void recover(string s) {
  vector<string> a;
  string t = "";
  for (int i = 0; i < s.size(); i++)
    if (s[i] != ':')
      t += s[i];
    else {
      if (i || t != "") a.push_back(t);
      t = "";
    }
  if (t != "") a.push_back(t);
  int rest = 9 - a.size(), cnt = 0;
  for (int i = 0; i < a.size(); i++)
    if (a[i] == "")
      for (int j = 0; j < rest; j++) {
        cout << "0000";
        if (++cnt < 8) cout << ":";
      }
    else {
      for (int j = 0; j < 4 - a[i].size(); j++) cout << "0";
      cout << a[i];
      if (++cnt < 8) cout << ":";
    }
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s;
    recover(s);
    if (i != n - 1) cout << endl;
  }
  return 0;
}
