#include <bits/stdc++.h>
using namespace std;
const long double pi = acos(-1.0);
const long double eps = 1e-9;
const double INF = 100000000000.0;
const long long MOD = 1000000009;
const int MAXN = 102400;
int main() {
  int tests;
  cin >> tests;
  for (long long test = 0; test < tests; ++test) {
    string s;
    cin >> s;
    if (s[0] == ':') s = "0000" + s;
    if (s[s.size() - 1] == ':') s += "0000";
    int sem = 0;
    for (long long i = 0; i < s.size(); ++i) sem += (s[i] == ':');
    if (sem == 8)
      for (long long i = 0; i < s.size(); ++i)
        if (s[i] == ':' && s[i + 1] == ':') {
          s.erase(i, 1);
          break;
        }
    for (long long i = 0; i < s.size() - 1; ++i)
      if (s[i] == ':' && s[i + 1] == ':') {
        string u = "0000";
        for (long long j = 0; j < 7 - sem; ++j) u += ":0000";
        s.insert(i + 1, u);
        break;
      }
    vector<string> a(1);
    for (long long i = 0; i < s.size(); ++i)
      if (s[i] == ':')
        a.push_back(string());
      else
        a.back().push_back(s[i]);
    for (long long i = 0; i < 8; ++i) {
      if (i) cout << ":";
      for (long long j = 0; j < 4 - a[i].size(); ++j) cout << "0";
      cout << a[i];
    }
    cout << endl;
  }
}
