#include <bits/stdc++.h>
using namespace std;
namespace SHENZHEBEI {
const int L = 2333333;
char SZB[L], *S = SZB, *T = SZB;
inline char gc() {
  if (S == T) {
    T = (S = SZB) + fread(SZB, 1, L, stdin);
    if (S == T) return '\n';
  }
  return *S++;
}
inline unsigned long long read() {
  unsigned long long x = 0;
  char ch = gc();
  for (; !isdigit(ch); ch = gc())
    ;
  for (; isdigit(ch); ch = gc()) x = x * 10 - 48 + ch;
  return x;
}
inline void write(unsigned long long x) {
  if (x >= 10) write(x / 10);
  putchar(x % 10 + '0');
}
inline char readchar() {
  char ch = gc();
  for (; isspace(ch); ch = gc())
    ;
  return ch;
}
inline unsigned long long readstr(char *s) {
  char ch = gc();
  int cur = 0;
  for (; isspace(ch); ch = gc())
    ;
  for (; !isspace(ch); ch = gc()) s[cur++] = ch;
  s[cur] = '\0';
  return cur;
}
inline void writeln(unsigned long long x) {
  write(x);
  puts("");
}
}  // namespace SHENZHEBEI
using namespace SHENZHEBEI;
const unsigned long long N = 1000010;
struct zyy {
  unsigned long long m[4][2][2];
  zyy() { memset(m, 0, sizeof m); }
} f[500010];
int head[N], nxt[N], vet[N], n, tot;
void insert(unsigned long long x, unsigned long long y) {
  nxt[++tot] = head[x];
  head[x] = tot;
  vet[tot] = y;
}
zyy merge(zyy a, zyy b) {
  zyy c;
  for (unsigned long long aj = 0; aj <= 1; ++aj)
    for (unsigned long long ak = 0; ak <= 1; ++ak)
      for (unsigned long long bj = 0; bj <= 1 - aj; ++bj)
        for (unsigned long long bk = 0; bk <= ak; ++bk) {
          c.m[0][aj + bj][ak ^ bk] += a.m[0][aj][ak] * b.m[0][bj][bk];
          c.m[1][aj + bj][ak ^ bk] += a.m[0][aj][ak] * b.m[1][bj][bk];
          c.m[1][aj + bj][ak ^ bk] += a.m[1][aj][ak] * b.m[0][bj][bk];
          c.m[2][aj + bj][ak ^ bk] += a.m[0][aj][ak] * b.m[2][bj][bk];
          c.m[2][aj + bj][ak ^ bk] += a.m[2][aj][ak] * b.m[0][bj][bk];
          c.m[3][aj + bj][ak ^ bk] += a.m[1][aj][ak] * b.m[1][bj][bk];
          c.m[3][aj + bj][ak ^ bk] += a.m[2][aj][ak] * b.m[2][bj][bk];
          c.m[3][aj + bj][ak ^ bk] += a.m[0][aj][ak] * b.m[3][bj][bk];
          c.m[3][aj + bj][ak ^ bk] += a.m[3][aj][ak] * b.m[0][bj][bk];
        }
  return c;
}
void link(zyy &x) { x.m[0][0][1] = x.m[1][0][0] = x.m[2][0][1] = 1; }
void cut(zyy &x) {
  x.m[1][1][0] += x.m[1][0][0];
  x.m[2][1][0] += x.m[2][0][0];
}
void Dfs(int x, int pre) {
  link(f[x]);
  for (unsigned long long i = head[x]; i; i = nxt[i])
    if (vet[i] ^ pre) Dfs(vet[i], x), f[x] = merge(f[x], f[vet[i]]);
  cut(f[x]);
}
int main() {
  n = read();
  for (unsigned long long i = 2; i <= n; ++i) {
    unsigned long long x = read(), y = read();
    insert(x, y);
    insert(y, x);
  }
  Dfs(1, 0);
  writeln(f[1].m[3][1][0]);
}

### Prompt

Construct a Cpp code solution to the problem outlined:

Sloth is bad, mkay? So we decided to prepare a problem to punish lazy guys.

You are given a tree, you should count the number of ways to remove an edge from it and then add an edge to it such that the final graph is a tree and has a perfect matching. Two ways of this operation are considered different if their removed edges or their added edges aren't the same. The removed edge and the added edge can be equal.

A perfect matching is a subset of edges such that each vertex is an endpoint of exactly one of these edges.

Input

The first line contains n (2 ≤ n ≤ 5·105) — the number of vertices.

Each of the next n - 1 lines contains two integers a and b (1 ≤ a, b ≤ n) — the endpoints of one edge. It's guaranteed that the graph is a tree.

Output

Output a single integer — the answer to the problem.

Examples

Input

4
1 2
2 3
3 4


Output

8


Input

5
1 2
2 3
3 4
3 5


Output

0


Input

8
1 2
2 3
3 4
1 5
5 6
6 7
1 8


Output

22

Note

In first sample, there are 8 ways:

  * edge between 2 and 3 turns to edge between 1 and 3, 
  * edge between 2 and 3 turns to edge between 1 and 4, 
  * edge between 2 and 3 turns to edge between 2 and 3, 
  * edge between 2 and 3 turns to edge between 2 and 4, 
  * edge between 1 and 2 turns to edge between 1 and 2, 
  * edge between 1 and 2 turns to edge between 1 and 4, 
  * edge between 3 and 4 turns to edge between 1 and 4, 
  * edge between 3 and 4 turns to edge between 3 and 4. 

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
namespace SHENZHEBEI {
const int L = 2333333;
char SZB[L], *S = SZB, *T = SZB;
inline char gc() {
  if (S == T) {
    T = (S = SZB) + fread(SZB, 1, L, stdin);
    if (S == T) return '\n';
  }
  return *S++;
}
inline unsigned long long read() {
  unsigned long long x = 0;
  char ch = gc();
  for (; !isdigit(ch); ch = gc())
    ;
  for (; isdigit(ch); ch = gc()) x = x * 10 - 48 + ch;
  return x;
}
inline void write(unsigned long long x) {
  if (x >= 10) write(x / 10);
  putchar(x % 10 + '0');
}
inline char readchar() {
  char ch = gc();
  for (; isspace(ch); ch = gc())
    ;
  return ch;
}
inline unsigned long long readstr(char *s) {
  char ch = gc();
  int cur = 0;
  for (; isspace(ch); ch = gc())
    ;
  for (; !isspace(ch); ch = gc()) s[cur++] = ch;
  s[cur] = '\0';
  return cur;
}
inline void writeln(unsigned long long x) {
  write(x);
  puts("");
}
}  // namespace SHENZHEBEI
using namespace SHENZHEBEI;
const unsigned long long N = 1000010;
struct zyy {
  unsigned long long m[4][2][2];
  zyy() { memset(m, 0, sizeof m); }
} f[500010];
int head[N], nxt[N], vet[N], n, tot;
void insert(unsigned long long x, unsigned long long y) {
  nxt[++tot] = head[x];
  head[x] = tot;
  vet[tot] = y;
}
zyy merge(zyy a, zyy b) {
  zyy c;
  for (unsigned long long aj = 0; aj <= 1; ++aj)
    for (unsigned long long ak = 0; ak <= 1; ++ak)
      for (unsigned long long bj = 0; bj <= 1 - aj; ++bj)
        for (unsigned long long bk = 0; bk <= ak; ++bk) {
          c.m[0][aj + bj][ak ^ bk] += a.m[0][aj][ak] * b.m[0][bj][bk];
          c.m[1][aj + bj][ak ^ bk] += a.m[0][aj][ak] * b.m[1][bj][bk];
          c.m[1][aj + bj][ak ^ bk] += a.m[1][aj][ak] * b.m[0][bj][bk];
          c.m[2][aj + bj][ak ^ bk] += a.m[0][aj][ak] * b.m[2][bj][bk];
          c.m[2][aj + bj][ak ^ bk] += a.m[2][aj][ak] * b.m[0][bj][bk];
          c.m[3][aj + bj][ak ^ bk] += a.m[1][aj][ak] * b.m[1][bj][bk];
          c.m[3][aj + bj][ak ^ bk] += a.m[2][aj][ak] * b.m[2][bj][bk];
          c.m[3][aj + bj][ak ^ bk] += a.m[0][aj][ak] * b.m[3][bj][bk];
          c.m[3][aj + bj][ak ^ bk] += a.m[3][aj][ak] * b.m[0][bj][bk];
        }
  return c;
}
void link(zyy &x) { x.m[0][0][1] = x.m[1][0][0] = x.m[2][0][1] = 1; }
void cut(zyy &x) {
  x.m[1][1][0] += x.m[1][0][0];
  x.m[2][1][0] += x.m[2][0][0];
}
void Dfs(int x, int pre) {
  link(f[x]);
  for (unsigned long long i = head[x]; i; i = nxt[i])
    if (vet[i] ^ pre) Dfs(vet[i], x), f[x] = merge(f[x], f[vet[i]]);
  cut(f[x]);
}
int main() {
  n = read();
  for (unsigned long long i = 2; i <= n; ++i) {
    unsigned long long x = read(), y = read();
    insert(x, y);
    insert(y, x);
  }
  Dfs(1, 0);
  writeln(f[1].m[3][1][0]);
}

```