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

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

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

j.t = i
h.t = m
h.o = m
k.t = j
n.t = h
n.o = h
c.t = j
m.t = h
m.o = h
a.t = i
i.t = j
assert m.t.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.txt = txt

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

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

j.t = i
h.t = m
h.o = m
k.t = j
n.t = h
n.o = h
c.t = j
m.t = h
m.o = h
a.t = i
i.t = j
assert m.t.o.o.txt == "h"