#include <stdio.h>

int main() {
    unsigned int ip1, ip2, ip3, ip4, num;
    while (scanf("%d.%d.%d.%d", &ip1, &ip2, &ip3, &ip4) != EOF) {
        scanf("%u", &num);
        unsigned int newip = ip4 + (ip3 << 8) + (ip2 << 16) + (ip1 << 24);
        int n1, n2, n3, n4;
        n1 = num >> 24;
        n2 = (num >> 16) & 255;
        n3 = (num >> 8) & 255; 
        n4 = num & 255;
        printf("%u\n%d.%d.%d.%d\n", newip, n1, n2, n3, n4);
    }
    return 0;
}