#include <bits/stdc++.h>
using namespace std;
char ip[10][10];
int main() {
  int n;
  cin >> n;
  getchar();
  for (int i = 0; i < n; ++i) {
    string str;
    getline(cin, str);
    int pos = 0;
    int l = 0;
    int fill = -1;
    memset(ip, 0, sizeof(ip));
    for (int j = 0; j < str.length(); ++j) {
      char temp = str[j];
      if (temp == ':' && str[j + 1] != ':') {
        ++pos;
        l = 0;
      } else if (temp == ':' && str[j + 1] == ':')
        fill = pos + 1;
      else if (temp != ':')
        ip[pos][l++] = temp;
    }
    if (fill == -1) {
      for (int j = 0; j < 8; ++j) {
        int len = strlen(ip[j]);
        if (j) cout << ':';
        cout << string(4 - len, '0');
        cout << ip[j];
      }
    } else {
      for (int j = 0; j < fill; ++j) {
        int len = strlen(ip[j]);
        if (j) cout << ':';
        cout << string(4 - len, '0');
        cout << ip[j];
      }
      for (int j = 0; j < 7 - pos; ++j) cout << ":0000";
      for (int j = fill; j <= pos; ++j) {
        int len = strlen(ip[j]);
        cout << ':' << string(4 - len, '0');
        cout << ip[j];
      }
    }
    cout << endl;
  }
  return 0;
}
