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

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

h = A("h")
m = B("m")
k = B("k")
j = B("j")
e = B("e")
g = B("g")
i = A("i")
b = A("b")

h.x = k
m.t = g
m.o = b
k.t = g
k.o = b
j.t = e
j.o = h
e.t = j
e.o = i
g.t = m
g.o = b
i.x = k
b.x = m
assert m.t.o.x.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

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

h = A("h")
m = B("m")
k = B("k")
j = B("j")
e = B("e")
g = B("g")
i = A("i")
b = A("b")

h.x = k
m.t = g
m.o = b
k.t = g
k.o = b
j.t = e
j.o = h
e.t = j
e.o = i
g.t = m
g.o = b
i.x = k
b.x = m
assert m.t.o.x.t.t.txt == "m"