class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.v: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.z: B = None
        self.s: B = None
        self.txt = txt

n = A("n")
c = B("c")
k = B("k")
f = A("f")
h = B("h")

n.y = h
n.v = f
c.z = h
c.s = h
k.z = h
k.s = h
f.y = k
f.v = n
h.z = c
h.s = c
assert n.y.s.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.v: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.z: B = None
        self.s: B = None
        self.txt = txt

n = A("n")
c = B("c")
k = B("k")
f = A("f")
h = B("h")

n.y = h
n.v = f
c.z = h
c.s = h
k.z = h
k.s = h
f.y = k
f.v = n
h.z = c
h.s = c
assert n.y.s.s.s.s.txt == "h"