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

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

c = A("c")
n = B("n")
h = B("h")
i = A("i")
b = A("b")
f = A("f")
l = A("l")

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

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

c = A("c")
n = B("n")
h = B("h")
i = A("i")
b = A("b")
f = A("f")
l = A("l")

c.u = i
c.o = n
n.t = b
h.t = c
i.u = c
i.o = n
b.u = f
b.o = h
f.u = l
f.o = h
l.u = b
l.o = h
assert c.o.t.o.t.txt == "c"