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

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

i = A("i")
a = B("a")
m = A("m")
h = B("h")
k = A("k")
d = B("d")
c = A("c")

i.w = k
i.v = c
a.u = d
m.w = k
m.v = c
h.u = a
k.w = c
k.v = c
d.u = h
c.w = m
c.v = i
assert h.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.v: A = None
        self.txt = txt

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

i = A("i")
a = B("a")
m = A("m")
h = B("h")
k = A("k")
d = B("d")
c = A("c")

i.w = k
i.v = c
a.u = d
m.w = k
m.v = c
h.u = a
k.w = c
k.v = c
d.u = h
c.w = m
c.v = i
assert h.u.u.u.txt == "h"