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

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

h = A("h")
j = B("j")
a = B("a")
f = A("f")
i = A("i")
l = A("l")
m = A("m")

h.w = i
j.t = a
j.v = l
a.t = j
a.v = m
f.w = h
i.w = f
l.w = f
m.w = i
assert j.t.t.v.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.txt = txt

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

h = A("h")
j = B("j")
a = B("a")
f = A("f")
i = A("i")
l = A("l")
m = A("m")

h.w = i
j.t = a
j.v = l
a.t = j
a.v = m
f.w = h
i.w = f
l.w = f
m.w = i
assert j.t.t.v.txt == "l"