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

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

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

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

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

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

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

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

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

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

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