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

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

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

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

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

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

i.t = f
l.t = i
l.x = k
h.t = k
h.x = a
m.t = i
m.x = k
k.t = d
j.t = a
j.x = k
d.t = k
d.x = i
f.t = i
f.x = a
a.t = m
assert h.t.t.x.t.x.t.txt == "m"