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

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

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

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

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

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

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

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

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