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

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

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

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

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

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

j.w = i
c.v = n
c.z = f
a.v = j
a.z = f
n.w = j
i.w = n
f.v = i
f.z = c
assert c.v.w.w.w.txt == "n"