#include <stdio.h>
using namespace std;
const int answer = {
{
{ 1048576 },
{ 524288, 0 },
{ 349526, 174763, 116793 },
{ 262144, 0, 87381, 0 },
{ 209716, 104858, 69906, 52429, 42025 },
{ 174763, 174763, 58482, 0, 34966, 58738 },
{ 149797, 74898, 49930, 37449, 29951, 25102, 22192 },
{ 131072, 131072, 43691, 0, 26215, 0, 18724, 0 },
{ 116509, 58254, 39143, 29127, 23272, 19494, 16416, 14564, 12740 },
{ 104858, 104858, 34945, 0, 22059, 34954, 14984, 0, 11676, 16370 },
},
{
{ 2097152 },
{ 1048576, 0 },
{ 699051, 349525, 233586 },
{ 524288, 524288, 174762, 524288 },
{ 419431, 209716, 139804, 104857, 84050 },
{ 349526, 349526, 116793, 174763, 69908, 0 },
{ 299594, 149797, 99849, 74898, 59914, 49934, 42632 },
{ 262144, 262144, 87382, 262144, 52429, 0, 37449, 0 },
{ 233017, 116508, 80102, 58254, 46553, 38937, 33296, 29127, 22775 },
{ 209716, 209716, 69840, 0, 41820, 0, 29956, 0, 23316, 0 },
},
{
{ 4194304 },
{ 2097152, 2097152 },
{ 1398102, 699051, 466489 },
{ 1048576, 1048576, 349526, 1048576 },
{ 838861, 419430, 279622, 209716, 167076 },
{ 699051, 0, 240306, 0, 139808, 232903 },
{ 599187, 299594, 199731, 149797, 120066, 99869, 86580 },
{ 524288, 0, 174762, 0, 104857, 0, 74898, 0 },
{ 466034, 233017, 155505, 116509, 93266, 77669, 66592, 58254, 45500 },
{ 419431, 419431, 139811, 0, 88506, 139812, 59918, 0, 46603, 85228 },
},
{
{ 8388608 },
{ 4194304, 4194304 },
{ 2796203, 1398102, 930930 },
{ 2097152, 0, 699051, 0 },
{ 1677722, 838861, 559072, 419431, 335790 },
{ 1398102, 1398102, 465124, 699051, 279629, 465465 },
{ 1198373, 599187, 399475, 299594, 239673, 199693, 171185 },
{ 1048576, 1048576, 349526, 0, 209715, 0, 149797, 0 },
{ 932068, 466034, 313121, 233017, 186404, 155268, 133184, 116508, 102830 },
{ 838861, 0, 279656, 0, 163850, 0, 119499, 0, 93210, 167895 },
},
{
{ 16777216 },
{ 8388608, 0 },
{ 5592406, 2796203, 1861860 },
{ 4194304, 4194304, 1398101, 0 },
{ 3355444, 1677722, 1118482, 838861, 668508 },
{ 2796203, 0, 928370, 0, 559261, 0 },
{ 2396746, 1198373, 799188, 599186, 479894, 399450, 342225 },
{ 2097152, 2097152, 699051, 2097152, 419430, 0, 299594, 0 },
{ 1864136, 932068, 620564, 466034, 372796, 311336, 266334, 233017, 207480 },
{ 1677722, 1677722, 559246, 838861, 336200, 0, 239664, 0, 186430, 335790 },
},
{
{ 33554432 },
{ 16777216, 0 },
{ 11184811, 5592405, 3726450 },
{ 8388608, 0, 2796203, 8388608 },
{ 6710887, 3355443, 2236492, 1677722, 1339066 },
{ 5592406, 0, 1865273, 0, 1118482, 1865273 },
{ 4793491, 2396745, 1597835, 1198373, 958656, 798926, 683134 },
{ 4194304, 0, 1398102, 0, 838861, 0, 599186, 0 },
{ 3728271, 1864135, 1243513, 932068, 745665, 621758, 532549, 466034, 415416 },
{ 3355444, 3355444, 1118482, 0, 669940, 0, 479363, 0, 372825, 671580 },
},
{
{ 67108864 },
{ 33554432, 33554432 },
{ 22369622, 11184811, 7427385 },
{ 16777216, 0, 5592406, 0 },
{ 13421773, 6710887, 4473913, 3355443, 2936024 },
{ 11184811, 11184811, 3727815, 5592406, 2236960, 0 },
{ 9586981, 4793491, 3195662, 2396746, 1917835, 1597852, 1369485 },
{ 8388608, 0, 2796202, 0, 1677721, 2796202, 1198372, 0 },
{ 7456541, 3728271, 2504936, 1864135, 1491308, 1241467, 1065216, 932068, 826507 },
{ 6710887, 0, 2236960, 0, 1258284, 0, 960915, 0, 745654, 1339884 },
},
{
{ 134217728 },
{ 67108864, 0 },
{ 44739243, 22369622, 14908530 },
{ 33554432, 33554432, 11184811, 0 },
{ 26843546, 13421773, 8947821, 6710887, 5348064 },
{ 22369622, 0, 7460409, 0, 4473881, 0 },
{ 19173962, 9586981, 6391332, 4793490, 3834790, 3195662, 2752575 },
{ 16777216, 16777216, 5592406, 0, 3355443, 0, 2396745, 0 },
{ 14913081, 7456541, 4973646, 3728270, 2982809, 2490326, 2130136, 1864135, 1638000 },
{ 13421773, 13421773, 4473923, 6710886, 2683028, 4473913, 1917385, 3355443, 1491305, 2687960 },
},
{
{ 268435456 },
{ 134217728, 0 },
{ 89478486, 44739243, 29830713 },
{ 67108864, 0, 22369621, 67108864 },
{ 53687092, 26843546, 17895696, 13421773, 10748560 },
{ 44739243, 0, 14920818, 22369621, 8947852, 14898290 },
{ 38347923, 19173962, 12782639, 9586981, 7669783, 6391316, 5448684 },
{ 33554432, 33554432, 11184811, 0, 6710886, 11184811, 4793490, 0 },
{ 29826162, 14913081, 9943572, 7456540, 5965699, 4971330, 4248744, 3728270, 3316040 },
{ 26843546, 26843546, 8947280, 0, 5347860, 8947849, 3834663, 0, 2982618, 5366907 },
},
{
{ 536870912 },
{ 268435456, 0 },
{ 178956971, 89478485, 59650503 },
{ 134217728, 134217728, 44739242, 0 },
{ 107374183, 53687091, 35791264, 26843545, 21391848 },
{ 89478486, 89478486, 29833444, 44739243, 17895670, 29709540 },
{ 76695845, 38347923, 25566082, 19173961, 15339233, 12782642, 10960562 },
{ 67108864, 67108864, 22369621, 0, 13421773, 0, 9586980, 0 },
{ 59652324, 29826162, 19806416, 14913081, 11930857, 9946754, 8521742, 7456541, 6599320 },
{ 53687092, 53687092, 17895696, 0, 10742006, 0, 7669573, 13421773, 5965249, 10743645 },
},
};
int main() {
int k, n, m, x, temp;
int answer = 0;
scanf("%d%d%d%d", &k
, &n
, &m
, &x
); int max = 1 << k;
if (n < m) {
temp = n;
n = m;
m = temp;
}
if (k >= 20 && n <= 10) {
printf("%d", answer
[k
- 20][n
- 1][m
- 1]); return 0;
}
for (int i = 0; i < max; i += n)
if ((x ^ i) % m == 0)
++answer;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiAKdXNpbmcgbmFtZXNwYWNlIHN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