#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string s;
  getline(cin, s);
  for (int p = 0; p < n; p++) {
    string s, news("");
    getline(cin, s);
    bool exp = false;
    bool athead = false;
    bool attail = false;
    if ((s[0] == ':') and (s[1] == ':')) {
      athead = true;
      s.assign(s, 2, s.size());
    };
    if ((s[s.size() - 1] == ':') and (s[s.size() - 2] == ':')) {
      attail = true;
      s.assign(s, 0, s.size() - 2);
    };
    int count = 0;
    int i = 0;
    while (i < s.size()) {
      count++;
      int j;
      for (j = i; j < s.size(); j++)
        if (s[j] == ':') break;
      int length = j - i;
      for (int k = 0; k < 4 - length; k++) news = news + "0";
      for (int k = i; k < j; k++) news = news + s[k];
      i = j + 1;
      if (j == s.size())
        break;
      else
        news = news + ':';
      if (s[i] == ':') {
        news = news + s[i++];
        exp = true;
      }
    };
    if (athead) {
      for (int i = 0; i < 8 - count; i++) news = "0000:" + news;
      if (count == 0) news.erase(news.size() - 1, 1);
    };
    if (attail) {
      for (int i = 0; i < 8 - count; i++) news = news + ":0000";
    };
    if (exp) {
      int h = news.find("::");
      news.erase(h, 1);
      for (int i = 0; i < 8 - count; i++) news = news.insert(h, ":0000");
    };
    cout << news << endl;
  };
};
