#include <bits/stdc++.h>
using namespace std;
string ss;
string s[8];
int p1, p2;
int n, k;
int main() {
  cin >> k;
  for (int test = 0; test < k; test++) {
    cin >> ss;
    ss = ":" + ss + ":";
    n = ss.size();
    for (int i = 0; i < n; i++) {
      if (ss[i] == ':') p2 = i;
      while (p2 - p1 < 5 && p2 - p1 > 1) {
        ss = ss.substr(0, p1 + 1) + "0" + ss.substr(p1 + 1, n - p1);
        p2++;
        n++;
      }
      p1 = p2;
    }
    n = ss.size();
    for (int i = 0; i < n; i++) {
      if (ss[i] == ':') p2 = i;
      if (p2 - p1 == 1) {
        ss = ss.substr(0, p1 + 1) + ss.substr(p1 + 2, n - p1);
        while (n <= 39) {
          ss = ss.substr(0, p1 + 1) + "0000:" + ss.substr(p1 + 1, n - p1);
          p2 += 5;
          n += 5;
        }
      }
      p1 = p2;
    }
    for (int i = 1; i < 40; i++) cout << ss[i];
    cout << endl;
  }
  return 0;
}
