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

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

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

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

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

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

a.v = c
a.w = c
f.u = a
e.u = a
j.u = a
i.u = c
c.v = a
c.w = a
assert a.v.v.w.w.w.txt == "c"