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

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

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

j = A("j")
h = B("h")
c = C("c")
d = B("d")
n = B("n")
e = B("e")
a = C("a")
b = C("b")

j.q = h
h.t = d
h.w = c
c.x = b
d.t = e
d.w = a
n.t = d
n.w = b
e.t = n
e.w = b
a.x = c
b.x = a
assert a.x.x.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.txt = txt

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

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

j = A("j")
h = B("h")
c = C("c")
d = B("d")
n = B("n")
e = B("e")
a = C("a")
b = C("b")

j.q = h
h.t = d
h.w = c
c.x = b
d.t = e
d.w = a
n.t = d
n.w = b
e.t = n
e.w = b
a.x = c
b.x = a
assert a.x.x.x.x.x.txt == "b"