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

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

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

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

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

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

a.t = g
a.o = j
j.p = e
j.s = e
e.t = k
e.o = j
k.p = a
k.s = f
m.t = k
m.o = j
g.p = m
g.s = m
i.t = k
i.o = b
b.p = m
b.s = a
f.t = b
f.o = j
assert a.t.p.t.s.o.s.txt == "e"