qyliang/CodeNanoFix huggingface dataset:
# Buggy code:
N = input()
As = [int(x) for x in input().split()]

new_As = []
for i in range(1, len(As)):
    if As[i-1] != As[i]:
        new_As.append(As[i-1])
As = new_As

idx = 0
mode_change_count = 1
while True:            
    if idx >= (len(As)-2):
        break
    if (As[idx+1] - As[idx])*(As[idx+2] - As[idx+1]) > 0:
        idx += 1
    elif (As[idx+1] - As[idx])*(As[idx+2] - As[idx+1]) < 0:
        idx += 2
        mode_change_count += 1

        
print(mode_change_count)

# Fixed code:
N = input()
As = [int(x) for x in input().split()]

new_As = [As[0]]
for i in range(1, len(As)):
    if As[i-1] != As[i]:
        new_As.append(As[i])
As = new_As

idx = 0
mode_change_count = 1
while True:            
    if idx >= (len(As)-2):
        break
    if (As[idx+1] - As[idx])*(As[idx+2] - As[idx+1]) > 0:
        idx += 1
    elif (As[idx+1] - As[idx])*(As[idx+2] - As[idx+1]) < 0:
        idx += 2
        mode_change_count += 1
  
print(mode_change_count)
# Buggy code:
n = int(input())
a = list(map(int, input().split()))

cnt = 0

jug = 2

for i in range(n - 1):
    if jug == 2:
        if a[i] < a[i+1]:
            jug = 0
        elif a[i] > a[i+1]:
            jug = 1 
    elif jug == 0:
        if a[i] > a[i+1]:
            jug = 2
            cnt += 1
    elif jug == 2:
        if a[i] < a[i+1]:
            jug = 0
            cnt +=1

print(cnt+1)


# Fixed code:
n = int(input())
a = list(map(int, input().split()))

cnt = 0
flag = 0
for i in range(n - 1):
    if flag == 0:
        if a[i] < a[i + 1]:
            flag = 1
        elif a[i] > a[i + 1]:
            flag = -1
    elif flag == 1:
        if a[i] < a[i + 1]:
            flag = 1
        elif a[i] > a[i + 1]:
            flag = 0
            cnt += 1
    elif flag == -1:
        if a[i] > a[i + 1]:
            flag = -1
        if a[i] < a[i + 1]:
            flag = 0
            cnt += 1
print(cnt + 1)
# Buggy code:
N = int(input())
A = list(map(int,input().split()))
count = 0
up = 0
down = 0
before = A[0]
tmp = 0
for i in range(1,N):
  tmp = A[i]
  if (up == 0) and (down == 0):
    if tmp > before:
      up = 1
      before = tmp
    elif tmp < before:
      down = 1
      before = tmp
    else:
      continue
  elif up == 1:
    if tmp < before:
      count += 1
      up = 0
      before = tmp
  elif down = 1:
    if tmp > before:
      count += 1
      down = 0
      before = tmp
count += 1
print(count)
      

# Fixed code:
N = int(input())
A = list(map(int, input().split()))
count = 0
up = 0
down = 0
before = A[0]
tmp = 0
for i in range(1,N):
  tmp = A[i]
  if (up == 0) and (down == 0):
    if tmp > before:
      up = 1
      before = tmp
    elif tmp < before:
      down = 1
      before = tmp
    else:
      continue
  elif up == 1:
    if tmp < before:
      count += 1
      up = 0
      before = tmp
    else:
      before = tmp
  elif down == 1:
    if tmp > before:
      count += 1
      down = 0
      before = tmp
    else:
      before = tmp
count += 1
print(count)
# Buggy code:
n=int(input())
a=list(map(int,input()))
t=1
p=a[0]
m=0
for i in a:
  if(p==i):
    continue
  if(m>0):
    if(i<p):
      t+=1
      m=0
  elif(m<0):
    if(i>p):
      t+=1
      m=0
  else:
    if(i>p):
      m=1
    eif(i<p):
      m=-1
  p=i
print(t)

# Fixed code:
n=int(input())
a=list(map(int,input().split()))
t=1
p=a[0]
m=0
for i in a:
  if(p==i):
    continue
  if(m>0):
    if(i<p):
      t+=1
      m=0
  elif(m<0):
    if(i>p):
      t+=1
      m=0
  else:
    if(i>p):
      m=1
    elif(i<p):
      m=-1
  p=i
print(t)
# Buggy code:
N = int(input())
A = list(map(int, input().split()))

count = 0
ans = 1
bef = 0
buff = True
for i in A:
    if count == 0:
        count = 1
    elif count == 1:
        if bef < i:
            count += 1
        elif bef > i:
            count += 1
            buff = False
        else:
            pass
    else:
        if buff:
            if bef <= i:
                pass
            else:
                ans += 1
                count = 1
        else:
            if bef >= i:
                pass
            else:
                ans += 1
                count = 1
    bef = i

# Fixed code:
N = int(input())
A = list(map(int, input().split()))

count = 0
ans = 1
bef = 0
buff = True
for i in A:
    if count == 0:
        count = 1
    elif count == 1:
        if bef < i:
            count += 1
            buff = True
        elif bef > i:
            count += 1
            buff = False
        else:
            pass
    else:
        if buff:
            if bef <= i:
                pass
            else:
                ans += 1
                count = 1
        else:
            if bef >= i:
                pass
            else:
                ans += 1
                count = 1
    bef = i
print(ans)
# Buggy code:
n = int(input())
a = list(map(int,input().split()))
state = 1
count = 1
tmp = a[0]
for i in a:
  if i == tmp:
    tmp = i
  elif i > tmp:
    state = 1
    break
  else:
    state = 0
    break
tmp = a[0]
for i in a:
  if i == tmp:
    pass
  elif i > tmp:
    if state == 1:
      pass
    else:
      state = 0
      count += 1
  else:
    if state == 0:
      pass
    else:
      state = 1
      count += 1
  tmp = i
print(count)

# Fixed code:
n = int(input())
a = list(map(int,input().split()))
state = 100
count = 1
tmp = a[0]
for i in a:
  if i == tmp:
    pass
  elif i > tmp:
    if state == 1:
      pass
    elif state == 0:
      count += 1
      state = 100
    else:
      state = 1
  else:
    if state == 0:
      pass
    elif state == 1:
      count += 1
      state = 100
    else:
      state = 0
  tmp = i
print(count)
# Buggy code:
n = int(input())
l = [int(x) for x in input().split()]

order = 0
subs = []
tmp = []

prev = 0
d = []
t = [l[0]]
for x in range(len(l)-1):
  a,b = l[x],l[x+1]
  c = a-b
  print(a,b,c, prev)
  if c == 0:
    t.append(b)
  elif prev == 0:
    t.append(b)
    prev = c
  elif (c < 0  and prev < 0) or (c > 0 and prev > 0):
    t.append(b)
  else:
    prev = 0
    d.append(t)
    t = [b]
d.append(t)


# Fixed code:
n = int(input())
l = [int(x) for x in input().split()]

order = 0
subs = []
tmp = []

prev = 0
d = []
t = [l[0]]
for x in range(len(l)-1):
  a,b = l[x],l[x+1]
  c = a-b
  # print(a,b,c, prev)
  if c == 0:
    t.append(b)
  elif prev == 0:
    t.append(b)
    prev = c
  elif (c < 0  and prev < 0) or (c > 0 and prev > 0):
    t.append(b)
  else:
    prev = 0
    d.append(t)
    t = [b]
d.append(t)

print(len(d))
# Buggy code:
N = int(input())
A = list(map(int, input().split()))

cnt = 1
inc = False
dec = False
p = A.pop(0)

for Ai in A:
    if (not inc) and (not dec):
        if Ai < p:
            dec = True
        else:
            inc = True
    elif inc:
        if Ai < p:
            cnt += 1
            inc = False
    elif dec:
        if Ai > p:
            cnt += 1
            dec = False
    p = Ai
    
print(cnt)

# Fixed code:
N = int(input())
A = list(map(int, input().split()))

cnt = 1
inc = False
dec = False
p = A.pop(0)

for Ai in A:
    if (not inc) and (not dec):
        if Ai < p:
            dec = True
        elif Ai > p:
            inc = True
    elif inc:
        if Ai < p:
            cnt += 1
            inc = False
    elif dec:
        if Ai > p:
            cnt += 1
            dec = False
    p = Ai
    
print(cnt)
# Buggy code:
N = int(input())
A = list(map(int,input().split()))

count = 1

for i in range(1,N-1):
  if A[i-1] > A[i]:
    up,down = 0,1
  elif A[i-1] < A[i]:
    up,down = 1,0
  if up == 1 and A[i] > A[i+1]:
    count += 1
  elif down == 1 and A[i] < A[i+1]:
    count += 1
    
print(count)


# Fixed code:
N = int(input())
A = list(map(int,input().split()))

count = 1
up,down = 1,1

for i in range(1,N):
  if A[i-1] > A[i]:
    up = 0
    if down == 0:
      count += 1
      up,down = 1,1
  elif A[i-1] < A[i]:
    down = 0
    if up == 0:
      count += 1
      up,down = 1,1

print(count)
# Buggy code:
n = int(input())
a = list(map(int, input().split()))
ans = 0
if n <= 2:
    print(1)
    exit()
pre = a[1] - a[0]
i = 2
while i < n:
    if pre * (a[i] - a[i-1]) < 0:
        ans += 1
        i += 1
        if i == n:
            break
    if a[i] != a[i-1]:
        pre = a[i] - a[i-1]
    i += 1
print(ans + 1)


# Fixed code:
n = int(input())
a = list(map(int, input().split()))
ans = 0
if n <= 2:
    print(1)
    exit()
pre = a[1] - a[0]
i = 2
while i < n:
    if pre * (a[i] - a[i-1]) < 0:
        ans += 1
        pre = 0
        i += 1
        if i == n:
            break
    if a[i] != a[i-1]:
        pre = a[i] - a[i-1]
    i += 1
print(ans + 1)
# Buggy code:
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    ans = 0
    i = 0
    while i < N:
        pos1, pos2 = i, i
        while pos1+1 < N and A[pos1] <= A[pos1+1]:
            pos1 += 1
        while pos2+1 < N and A[pos2] > A[pos2+1]:
            pos2 += 1
        ans += 1
        i = max(pos1, pos2) + 1
    print(ans)


if __name__ == '__main__':
    main()


# Fixed code:
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    ans = 0
    i = 0
    while i < N:
        while i+1 < N and A[i] == A[i+1]:
            i += 1
        pos1, pos2 = i, i
        while pos1+1 < N and A[pos1] <= A[pos1+1]:
            pos1 += 1
        while pos2+1 < N and A[pos2] >= A[pos2+1]:
            pos2 += 1
        ans += 1
        i = max(pos1, pos2) + 1
    print(ans)


if __name__ == '__main__':
    main()
# Buggy code:
N = int(input())
A = list(map(int, input().split()))

ans = 1
up,down = False,False
for i in range(N-1):
  if A[i] < A[i+1]:
    up = True
  elif A[i] > A[i+1]:
    down = True
  if up and dn:
    ans +=1
    up,down = False,False
    
print(ans)

# Fixed code:
N = int(input())
A = list(map(int,input().split()))

up = False
down = False
count = 1
for i in range(N-1):
    if A[i] < A[i+1]:
        up = True
    elif A[i] > A[i+1]:
        down = True
    if up ==True and down == True:
        count += 1
        up = False
        down = False
print(count)
# Buggy code:
from collections import deque

n = int(input())
a = list(map(int,input().split()))
d = deque(a)

tmp = []
cnt = 0
while d:
  v = d.popleft()
  if len(tmp)<=1:
    pass
  else:
    if not v >= tmp[-1] >= tmp[-2] or v <= tmp[-1] <= tmp[-2]:
      tmp = []
      cnt += 1
  tmp.append(v)
#  print(d,tmp,cnt)
if tmp:
  cnt+=1
print(cnt)

# Fixed code:
from collections import deque
 
n = int(input())
a = list(map(int,input().split()))
d = deque(a)
 
tmp = []
cnt = 0
while d:
  v = d.popleft()
  if len(tmp)<=1:
    pass
  else:
    if not (v >= tmp[-1] >= tmp[-2] >= tmp[0] or v <= tmp[-1] <= tmp[-2] <= tmp[0]):
      tmp = []
      cnt += 1
  tmp.append(v)
#  print(d,tmp,cnt)
if tmp:
  cnt+=1
print(cnt)
# Buggy code:
n = int(input())
a = [int(c) for c in input().split(' ')]
prev = None
c = 1
inc = None

for i in range(l):
    current = a[i]
    if i == 0 :
        continue
    if inc == None:
        if a[i] > a[i-1] :
            inc = True
        elif             a[i] < a[i - 1]:
            inc = False
        else:
            continue 
    elif inc == True:
        if a[i-1] < a[i]:
            pass
        elif a[i -1] > a[i]:
            c += 1
            inc = None
    elif inc == False:
        if a[i-1] > a[i]:
            pass
        elif a[i - 1] < a[i]:
            c += 1
            inc = None
print(c)


# Fixed code:
n = int(input())
a = [int(c) for c in input().split(' ')]
#a = [1 ,2 ,1 ,2 ,1 ,2 ,1 ,2 ,1]
l = len(a)
prev = None
c = 1
inc = None

for i in range(l):
    current = a[i]
    if i == 0 :
        continue
    if inc == None:
        if a[i] > a[i-1] :
            inc = True
        elif             a[i] < a[i - 1]:
            inc = False
        else:
            continue 
    elif inc == True:
        if a[i-1] < a[i]:
            pass
        elif a[i -1] > a[i]:
            c += 1
            inc = None
    elif inc == False:
        if a[i-1] > a[i]:
            pass
        elif a[i - 1] < a[i]:
            c += 1
            inc = None
print(c)
# Buggy code:
import numpy as np

n = int(input())
a = list(map(int,input().split()))

flg = np.sign(a[1] - a[0])
skp = 1
cnt = 1
temp = a[0]
for i in range(1,n):
    dif = a[i] - temp
    direct = np.sign(dif)
    if dif != 0:
        if skp:
            flg = direct
            skp = 0
            continue
            
        elif direct != flg:
            flg = direct
            cnt+=1
            skp = 1
    temp = a[i]
print(cnt)

# Fixed code:
import numpy as np

n = int(input())
a = list(map(int,input().split()))

cnt = 1
direct = 0
temp = a[0]
for i in range(1,n):
    dif = a[i] - temp
    if dif != 0:
        if direct == 0:
            direct = np.sign(dif)
            
        elif np.sign(a[i] - temp) != direct:
            cnt+=1
            direct = 0
    temp = a[i]
print(cnt)
# Buggy code:
# coding: utf-8
# Your code here!
_=int(input())
A=list(map(int,input().split()))
N=len(A)

trend=0
ans=0
for i in range(N-1):
    temp=A[i+1]-A[i]
    if trend==0:
        if temp>0:
            trend=1
            ans+=1
        elif temp<0:
            trend=-1
            ans+=1
        else:
            pass
    elif trend==1:
        if temp>0:
            pass
        elif temp<0:
            trend=0
        else:
            pass
    elif trend==-1:
        if temp>0:
            trend=0
        elif temp<0:
            pass
        else:
            pass
print(trend)
print(ans if trend!=0 else ans+1)


# Fixed code:
# coding: utf-8
# Your code here!
_=int(input())
A=list(map(int,input().split()))
N=len(A)

trend=0
ans=0
for i in range(N-1):
    temp=A[i+1]-A[i]
    if trend==0:
        if temp>0:
            trend=1
            ans+=1
        elif temp<0:
            trend=-1
            ans+=1
        else:
            pass
    elif trend==1:
        if temp>0:
            pass
        elif temp<0:
            trend=0
        else:
            pass
    elif trend==-1:
        if temp>0:
            trend=0
        elif temp<0:
            pass
        else:
            pass

print(ans if trend!=0 else ans+1)
# Buggy code:
n=int(input())
a=list(map(int,input().split()))
ans=1
temp=0
for i in range(1,n):
  if a[i-1]<a[i] and temp==0:
    temp=1
  elif a[i-1]>a[i] and temp==0:
    temp=2
  elif a[i-1]>a[i] and temp==1:
    temp=2
    ans=ans+1
  elif a[i-1]<a[i] and temp==2:
    temp=1
    ans=ans+1
print(ans)

# Fixed code:
n = int(input())
a = list(map(int,input().split()))
p = 0
ans = 0
for i in range(1,n):
    if p == 0 and a[i-1] < a[i]:
        p = 1
    elif p == 0 and a[i-1] > a[i]:
        p = 2
    elif p == 1 and a[i-1] > a[i]:
        p = 0
        ans += 1
    elif p == 2 and a[i-1] < a[i]:
        p = 0
        ans += 1
print(ans+1)
# Buggy code:
import itertools

n, m = map(int, input().split())
edge = [[0]*n]*n

for i in range(m):
    s, e = map(int, input().split())
    s -= 1
    e -= 1
    edge[s][e] = 1
    edge[e][s] = 1
    
result = 0

cands= list(itertools.permutations(range(1, n)))

def search(cand):
    cand = [0].extend(cand)
    for i in range(1, n):
        if edge[i-1][i] == 0:
            return False
        else:
            return True
for cand in cands:
    result += search(cand)
    
print(result)

# Fixed code:
import itertools

n, m = map(int, input().split())
edge = zeros = [ [0]*n for _ in range(n) ]

for i in range(m):
    s, e = map(int, input().split())
    s -= 1
    e -= 1
    edge[s][e] = 1
    edge[e][s] = 1
    
result = 0

cands= list(itertools.permutations(range(1, n)))

def search(cand):
    cand = [0].extend(cand)
    for i in range(1, n):
        if edge[i-1][i] == 0:
            return False
    return True
for cand in cands:
    result += search(cand)
    
result = 0

cands= list(itertools.permutations(range(1, n)))

def search(cand):
    cand = list(cand)
    cand.insert(0, 0)
    for i in range(1, n):
        if edge[cand[i-1]][cand[i]] == 0:
            return False
    return True
for cand in cands:
    result += search(cand)
    
print(result)
# Buggy code:
def dfs(i):
  global count
  global seen
  global G

  print(seen)
  end = True
  for n in range(N):
    if seen[n] == 0 and n != i:
      end = False

  if (end):
    count += 1
    return

  seen[i] = 1
  for g in G:
    if g[0] == i:
      if seen[g[1]] == 1:
        continue
      dfs(g[1])
  
    if g[1] == i:
      if seen[g[0]] == 1:
        continue
      dfs(g[0])

  seen[i] == 0

N, M = map(int, input().split())
li = [list(map(int, input().split())) for n in range(M)]

G = []

for i in li:
  G.append([i[0]-1, i[1]-1])

count = 0
seen = [0] * N
dfs(0)

print(count)

# Fixed code:
def dfs(i):
  global count
  global seen
  global G

  end = True
  for n in range(N):
    if seen[n] == 0 and n != i:
      end = False

  if (end):
    count += 1
    return

  seen[i] = 1
  for g in G:
    if g[0] == i:
      if seen[g[1]] == 1:
        continue
      dfs(g[1])
  
    if g[1] == i:
      if seen[g[0]] == 1:
        continue
      dfs(g[0])

  seen[i] = 0

N, M = map(int, input().split())
li = [list(map(int, input().split())) for n in range(M)]

G = []

for i in li:
  G.append([i[0]-1, i[1]-1])

count = 0
seen = [0] * N
dfs(0)

print(count)
# Buggy code:
import itertools
N,M=map(int,input().split())
edges={tuple(sorted(map(int,input().split()))) for i in range(M)}
ans=0
for i in itertools.permutations(range(2,N+1),N-1):
    print(i)
    l=[1]+list(i)
    ans+=sum(1 for edge in zip(l,l[1:]) if tuple(sorted(edge)) in edges)==N-1
print(ans)

# Fixed code:
import itertools
N,M=map(int,input().split())
edges={tuple(sorted(map(int,input().split())))for i in range(M)}
ans=0
for i in itertools.permutations(range(2,N+1),N-1):
    l=[1]+list(i)
    ans+=sum(1 for edge in zip(l,l[1:])if tuple(sorted(edge))in edges)==N-1
print(ans)
# Buggy code:
import itertools
n,m=map(int,input().split())
l=[list(map(int,input().split())) for i in range(m)]
s=list(itertools.permutations(range(1,n+1)))
count=0
for lis in s:
    flag=False
    if lis[0]==1:
        if all([lis[i],lis[i+1]] in l for i in range(n-1)):
            count+=1
        elif all([lis[i+1],lis[i]] in l for i in range(n-1)):
            count+=1
print(count)

# Fixed code:
import itertools
n,m=map(int,input().split())
l=[list(map(int,input().split())) for i in range(m)]
s=list(itertools.permutations(range(1,n+1)))
count=0
for lis in s:
    flag=False
    if lis[0]==1:
        if all([lis[i],lis[i+1]] in l or [lis[i+1],lis[i]] in l for i in range(n-1)):
            count+=1          
print(count)
# Buggy code:
N,M = map(int,input().split())
edge_list = [list() for i in range(N)]
for i in range(M):
        a,b = map(int,input().split())
        edge_list[a-1].append(b-1)
        edge_list[b-1].append(a-1)
done = [0] * n
chk = 0
def dfs(s,done):
    done = done[:]
    global chk
    done[s] = True 
    if all(done):
        chk += 1
    for i in edges[u]:
        if not done[i]:
            dfs(i.done)
    return 0
dfs(0,done)
print(chk)

# Fixed code:
N,M = map(int,input().split())
edge_list = [list() for i in range(N)]
for i in range(M):
        a,b = map(int,input().split())
        edge_list[a-1].append(b-1)
        edge_list[b-1].append(a-1)
done = [0] * N
chk = 0
def dfs(s,done):
    done = done[:]
    global chk
    done[s] = True
    if all(done):
        chk += 1
    for i in edge_list[s]:
        if not done[i]:
            dfs(i,done)
    return 0
dfs(0,done)
print(chk)
# Buggy code:
import numpy as np
n,m=map(int,input().split())
if m==0:
    print(0)
    exit()
ans=[[] for i in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    ans[a-1].append((b-1))
    ans[b-1].append((a-1))
v=[]
def dfs(now,visited=[]):
    global v
    if len(visited)==n:
        v.append([visited])
        return
    for j in ans[now]:
        for j not in visited:
            dfs(j,visited+[j])
dfs(0,[0])
print(len(v))

# Fixed code:
import numpy as np
n,m=map(int,input().split())
if m==0:
    print(0)
    exit()
ans=[[] for i in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    ans[a-1].append((b-1))
    ans[b-1].append((a-1))
v=[]
def dfs(now,visited=[]):
    global v
    if len(visited)==n:
        v.append([visited])
        return
    for j in ans[now]:
        if j not in visited:
            dfs(j,visited+[j])
dfs(0,[0])
print(len(v))
# Buggy code:
N,M = map(int, input().split())
L = [list(map(int,input().split())) for _ in range(M)]
graph = [[False] * (N + 1) for _ in range(N + 1)]
#%%

for i in L:
    graph[i[0]][i[1]] = True
    graph[i[1]][i[0]] = True

graph[0][1] = True
graph[1][0] = True
#%%
ans = 0
for i in permutations(range(1, N + 1)):
    if i[0] != 1:
        continue
    for j in range(1, N):
        if not graph[i[j - 1]][i[j]]:
            break
    else:
       ans += 1 

print(ans)


# Fixed code:
from   itertools import   permutations

N,M = map(int, input().split())
L = [list(map(int,input().split())) for _ in range(M)]
graph = [[False] * (N + 1) for _ in range(N + 1)]
#%%

for i in L:
    graph[i[0]][i[1]] = True
    graph[i[1]][i[0]] = True

graph[0][1] = True
graph[1][0] = True
#%%
ans = 0
for i in permutations(range(1, N + 1)):
    if i[0] != 1:
        continue
    for j in range(1, N):
        if not graph[i[j - 1]][i[j]]:
            break
    else:
       ans += 1 

print(ans)
# Buggy code:
n,m=map(int, input().split())
ab=[list(map(int, input().split())) for _ in range(m)]
graph=[[False for _ in range(n)] for _ in range(n)]
visited=[False for _ in range(n)]
visited[0]=True

for x in ab:
    graph[x[0]-1][x[1]-1]=True

def dfs(v,ret,n,visited):
    all_visited=True
    for i in range(n):
        if visited[i]==False:
            all_visited=False
    if all_visited:
        return 1
    for i in range(n):
        if graph[v][i]==False:
            continue
        if visited[i]:
            continue
        visited[i]=True
        ret+=dfs(i,ret,n,visited)
        visited[i]=False
    return ret
print(dfs(0,0,n,visited))

# Fixed code:
n,m=map(int, input().split())
ab=[list(map(int, input().split())) for _ in range(m)]
graph=[[False for _ in range(n)] for _ in range(n)]
visited=[False for _ in range(n)]
visited[0]=True

for x in ab:
    graph[x[0]-1][x[1]-1]=True
    graph[x[1]-1][x[0]-1]=True
def dfs(v,n,visited):
    all_visited=True
    for i in range(n):
        if visited[i]==False:
            all_visited=False
    if all_visited:
        return 1
    ret=0
    for i in range(n):
        if graph[v][i]==False:
            continue
        if visited[i]:
            continue
        visited[i]=True
        ret+=dfs(i,n,visited)
        visited[i]=False
    return ret
print(dfs(0,n,visited))
# Buggy code:
import itertools

N,M = map(int, input().split())
path = [[False] * N for x in range(N)]

for i in range(M):
    a,b = map(int, input().split())
    a,b = a-1, b-1
    path[a][b] = True
    path[b][a] = True

count = 0
for j in itertools.permutations(range(N),M):
    if j[0] != 1:
        continue
    for k in range(M-1):
        if k == M-2:
            count += 1
            break
        if path[j[k]][j[k+1]] == 'False':
            break
print(count)

# Fixed code:
import itertools

N,M = map(int, input().split())
path = [[False] * N for x in range(N)]

for i in range(M):
    a,b = map(int, input().split())
    a,b = a-1, b-1
    path[a][b] = True
    path[b][a] = True

count = 0
for j in itertools.permutations(range(N)):
    if j[0] != 0:
        continue
    for k in range(N):
        if k == N-1:
            count += 1
            break
        if not path[j[k]][j[k+1]]:
            break
print(count)
# Buggy code:
import itertools

n,m = map(int,input().xplit())
path=[[False]*n for _ in range(n)]
for _ in range(m):
  a,b = map(int,input().split())
  a-=1
  b-=1
  path[a][b]=True
  path[b][a]=True
ans=0

for i in itertools.permutations(range(6), 6):
   if i[0] == 0:
     for j in range(n):
       if j==n-1:
         ans+=1
         break
       if not path[i[j-1]][i[j]]:
         break

print(ans)

# Fixed code:
import itertools

n,m = map(int,input().split())
path=[[False]*n for _ in range(n)]
for _ in range(m):
  a,b = map(int,input().split())
  a-=1
  b-=1
  path[a][b]=True
  path[b][a]=True
ans=0

for i in itertools.permutations(range(n),n):
   if i[0] == 0:
     for j in range(n):
       if j==n-1:
         ans+=1
         break
       if not path[i[j]][i[j+1]]:
         break

print(ans)