#include <stdio.h>
#include <stdlib.h>
#include <string.h>

char* encrypt(char* plain, int key[][3]);

int main() {

    int k[3][3] = {{6,2,5},{3,23,9},{5,8,7}};
    char word[100];

    // I typed in "septic" and got the ciphertext "jvtkzr" which is correct.
    scanf("%s", word);
    char* cipher = encrypt(word, k);
    printf("%s\n", cipher);
    free(cipher);

    return 0;
}

char* encrypt(char* plain, int key[][3]) {

    int n = strlen(plain);
    char* cipher = calloc(n+1, sizeof(char));

    // Please pay attention to the increment statement.
    for (int i=0; i<n; i+=3) {

        for (int j=0; j<3; j ++) {
            int val = 0;
            for (int k=0; k<3; k++)
                val = (val + key[j][k]*(plain[i+k]-'a'))%26;
            cipher[i+j] = 'a' + val;
        }
    }
    cipher[n] = '\0';
    return cipher;
}
