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

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

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

n.z = c
j.v = c
j.u = f
c.z = n
f.z = n
i.v = n
i.u = f
e.v = c
e.u = c
assert f.z.z.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.txt = txt

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

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

n.z = c
j.v = c
j.u = f
c.z = n
f.z = n
i.v = n
i.u = f
e.v = c
e.u = c
assert f.z.z.z.z.txt == "c"