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

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

f = A("f")
i = B("i")
e = B("e")
n = A("n")
j = B("j")
h = B("h")

f.w = j
f.v = n
i.y = h
i.z = n
e.y = j
e.z = f
n.w = e
n.v = f
j.y = h
j.z = n
h.y = j
h.z = n
assert i.y.y.y.y.y.z.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.v: A = None
        self.txt = txt

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

f = A("f")
i = B("i")
e = B("e")
n = A("n")
j = B("j")
h = B("h")

f.w = j
f.v = n
i.y = h
i.z = n
e.y = j
e.z = f
n.w = e
n.v = f
j.y = h
j.z = n
h.y = j
h.z = n
assert i.y.y.y.y.y.z.txt == "n"