#include <bits/stdc++.h>
using
namespace
std;
struct
Node {
int
key;
struct
Node *left, *right;
};
Node* newNode(
int
key)
{
Node* temp =
new
Node;
temp->key = key;
temp->left = temp->right = NULL;
return
(temp);
}
bool
PathXor(vector<
int
>& path)
{
int
ans = 0;
for
(
auto
x : path) {
ans ^= x;
}
return
(ans != 0);
}
void
printPaths(vector<
int
>& path)
{
for
(
auto
x : path) {
cout << x <<
" "
;
}
cout << endl;
}
void
findPaths(
struct
Node* root,
vector<
int
>& path)
{
if
(root == NULL)
return
;
path.push_back(root->key);
findPaths(root->left, path);
findPaths(root->right, path);
if
(root->left == NULL
&& root->right == NULL) {
if
(PathXor(path)) {
printPaths(path);
}
}
path.pop_back();
}
void
printPaths(
struct
Node* node)
{
vector<
int
> path;
findPaths(node, path);
}
int
main()
{
Node* root = newNode(10);
root->left = newNode(10);
root->right = newNode(3);
root->right->left = newNode(10);
root->right->right = newNode(3);
root->right->left->left = newNode(7);
root->right->left->right = newNode(3);
root->right->right->left = newNode(42);
root->right->right->right = newNode(13);
root->right->right->right->left = newNode(7);
printPaths(root);
return
0;
}