//
// Created by gs on 2026/3/4.
//


// HJ33 整数与IP地址间的转换

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main() {
    char buf[30];
    unsigned char aa = 0;
    unsigned int result = 0;
    char cell[10] = {0};
    char ip_str[30] = {0};

    while (scanf("%s", buf) != EOF) {

        char* p = strchr(buf, '.');
        if (p == NULL) {
            // 数字
            unsigned int num = atoi(buf);
            sprintf(ip_str, "%d.%d.%d.%d", (num & 0xff000000) >> 24, (num & 0xff0000) >> 16,
                    (num & 0xff00) >> 8,
                    num & 0xff);

            printf("%s\n", ip_str);
        } else {
            // ip
            int j = 0;
            for (int i = 0; i <= strlen(buf); i++) {
                if (i == strlen(buf) || buf[i] == '.') {
                    cell[j] = '\0';
                    int num = atoi(cell);
                    result = result << 8;
                    result += num;
                    j = 0;
                } else {
                    cell[j] = buf[i];
                    j++;
                }
            }

            printf("%u\n", result);
        }
    }


    return 0;
}