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

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

c = A("c")
h = B("h")
f = B("f")
n = B("n")
m = A("m")
l = B("l")
k = B("k")
b = A("b")
e = B("e")

c.o = h
c.t = b
h.t = f
f.t = e
n.t = h
m.o = f
m.t = c
l.t = h
k.t = n
b.o = h
b.t = m
e.t = l
assert b.o.t.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.t: A = None
        self.txt = txt

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

c = A("c")
h = B("h")
f = B("f")
n = B("n")
m = A("m")
l = B("l")
k = B("k")
b = A("b")
e = B("e")

c.o = h
c.t = b
h.t = f
f.t = e
n.t = h
m.o = f
m.t = c
l.t = h
k.t = n
b.o = h
b.t = m
e.t = l
assert b.o.t.t.t.t.txt == "h"