class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.u: A = None
        self.t: E = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.r: E = None
        self.txt = txt

m = A("m")
h = B("h")
f = C("f")
k = D("k")
d = E("d")
j = A("j")
b = B("b")
g = C("g")
a = E("a")

m.y = k
h.q = b
h.t = m
f.x = k
f.t = k
f.r = b
k.u = m
k.t = d
d.r = a
j.y = k
b.q = h
b.t = m
g.x = k
g.t = k
g.r = h
a.r = d
assert a.r.r.r.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.u: A = None
        self.t: E = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.r: E = None
        self.txt = txt

m = A("m")
h = B("h")
f = C("f")
k = D("k")
d = E("d")
j = A("j")
b = B("b")
g = C("g")
a = E("a")

m.y = k
h.q = b
h.t = m
f.x = k
f.t = k
f.r = b
k.u = m
k.t = d
d.r = a
j.y = k
b.q = h
b.t = m
g.x = k
g.t = k
g.r = h
a.r = d
assert a.r.r.r.r.r.r.txt == "a"