#include <cstring>
#include <algorithm>
#include <iostream>
void DFS(int (&used)[20], const int (&m)[20][20], int c, int& maxn, int k, int v) {
used[v] = 1;
k += 1;
if(k > maxn)
maxn = k;
for(int i = 0; i < c; ++i) {
if(!used[i] && m[v][i] == 1) {
DFS(used, m, c, maxn, k, i);
}
}
used[v] = 0;
}
int main() {
const long a[20] = {1, 1, 3, 7, 13};
const int c = 5;
int m[20][20];
memset(m, 0, sizeof(m));
for(int i = 0; i < c; ++i) {
for(int j = i + 1; j < c; ++j) {
if( (a[i] % a[j] == 0) || (a[j] % a[i] == 0) ) {
m[i][j] = m[j][i] = 1; // Creating 2D array
}
}
}
int maxn = 0;
for(int i = 0; i < c; ++i) {
int used[20];
int k = 0;
memset(used, 0, sizeof(used));
DFS(used, m, c, maxn, k, i);
}
std::cout << maxn << std::endl;
}
I2luY2x1ZGUgPGNzdHJpbmc+CiNpbmNsdWRlIDxhbGdvcml0aG0+CiNpbmNsdWRlIDxpb3N0cmVhbT4KCgp2b2lkIERGUyhpbnQgKCZ1c2VkKVsyMF0sIGNvbnN0IGludCAoJm0pWzIwXVsyMF0sIGludCBjLCBpbnQmIG1heG4sIGludCBrLCBpbnQgdikgewogICAgdXNlZFt2XSA9IDE7CiAgICBrICs9IDE7CiAgICBpZihrID4gbWF4bikKICAgICAgICBtYXhuID0gazsKICAgIGZvcihpbnQgaSA9IDA7IGkgPCBjOyArK2kpIHsKICAgICAgICBpZighdXNlZFtpXSAmJiBtW3ZdW2ldID09IDEpIHsKICAgICAgICAgICAgREZTKHVzZWQsIG0sIGMsIG1heG4sIGssIGkpOwogICAgICAgIH0KICAgIH0KICAgIHVzZWRbdl0gPSAwOwp9CgppbnQgbWFpbigpIHsKICAgIGNvbnN0IGxvbmcgYVsyMF0gPSB7MSwgMSwgMywgNywgMTN9OwoJY29uc3QgaW50IGMgPSA1OwoKCWludCBtWzIwXVsyMF07CiAgICBtZW1zZXQobSwgMCwgc2l6ZW9mKG0pKTsKCiAgICBmb3IoaW50IGkgPSAwOyBpIDwgYzsgKytpKSB7CiAgICAgICAgZm9yKGludCBqID0gaSArIDE7IGogPCBjOyArK2opIHsKICAgICAgICAgICAgaWYoIChhW2ldICUgYVtqXSA9PSAwKSB8fCAoYVtqXSAlIGFbaV0gPT0gMCkgKSB7CiAgICAgICAgICAgICAgICBtW2ldW2pdID0gbVtqXVtpXSA9IDE7IC8vIENyZWF0aW5nIDJEIGFycmF5CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICB9CgoJaW50IG1heG4gPSAwOwogICAgZm9yKGludCBpID0gMDsgaSA8IGM7ICsraSkgewogICAgCWludCB1c2VkWzIwXTsKICAgICAgICBpbnQgayA9IDA7CiAgICAgICAgbWVtc2V0KHVzZWQsIDAsIHNpemVvZih1c2VkKSk7CiAgICAgICAgREZTKHVzZWQsIG0sIGMsIG1heG4sIGssIGkpOwogICAgfQogICAgc3RkOjpjb3V0IDw8IG1heG4gPDwgc3RkOjplbmRsOwp9Cg==