#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  while (n-- > 0) {
    string s;
    cin >> s;
    bool hasDouble = false;
    for (int i = 1; i < s.length(); i++)
      if (s[i] == ':' && s[i - 1] == ':') {
        s.insert(i, "#");
        break;
      }
    if (s[0] == ':') s = s.substr(1);
    if (s[s.length() - 1] == ':') s = s.substr(0, s.length() - 1);
    int nsc = 0;
    for (int i = 0; i < s.length(); i++)
      if (s[i] == ':') nsc++;
    for (int i = 0; i < s.length(); i++) {
      if (s[i] == '#') {
        int g = 8 - nsc;
        for (int i = 0; i < g; i++) cout << "0000" << (i < g - 1 ? ":" : "");
      } else if (s[i] == ':') {
        cout << ':';
      } else {
        int nextSc = i + 1;
        while (nextSc < s.length() && s[nextSc] != ':') nextSc++;
        for (int j = 0; j < 4 - (nextSc - i); j++) cout << '0';
        while (i < nextSc) cout << s[i++];
        i--;
      }
    }
    cout << '\n';
  }
}
