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

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

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

f = A("f")
h = B("h")
n = C("n")
j = B("j")
i = B("i")
c = A("c")
g = C("g")
m = C("m")
b = C("b")

f.t = g
h.o = i
h.x = i
n.t = g
j.o = h
j.x = h
i.o = j
i.x = h
c.t = m
g.t = b
m.t = g
b.t = n
assert n.t.t.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

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

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

f = A("f")
h = B("h")
n = C("n")
j = B("j")
i = B("i")
c = A("c")
g = C("g")
m = C("m")
b = C("b")

f.t = g
h.o = i
h.x = i
n.t = g
j.o = h
j.x = h
i.o = j
i.x = h
c.t = m
g.t = b
m.t = g
b.t = n
assert n.t.t.t.t.t.txt == "b"