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

class B:
    def __init__(self, txt: str):
        self.r: D = None
        self.z: D = None
        self.y: C = None
        self.v: D = None
        self.txt = txt

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

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

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

k = A("k")
d = B("d")
l = C("l")
i = D("i")
a = E("a")
g = B("g")
b = E("b")
c = B("c")
m = A("m")

k.q = b
d.r = i
d.z = i
d.v = i
d.y = l
l.x = m
i.u = c
a.x = l
a.p = l
g.r = i
g.z = i
g.v = i
g.y = l
b.x = l
b.p = l
c.r = i
c.z = i
c.v = i
c.y = l
m.q = a
assert a.p.x.q.x.x.q.x.x.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: E = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.r: D = None
        self.z: D = None
        self.y: C = None
        self.v: D = None
        self.txt = txt

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

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

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

k = A("k")
d = B("d")
l = C("l")
i = D("i")
a = E("a")
g = B("g")
b = E("b")
c = B("c")
m = A("m")

k.q = b
d.r = i
d.z = i
d.v = i
d.y = l
l.x = m
i.u = c
a.x = l
a.p = l
g.r = i
g.z = i
g.v = i
g.y = l
b.x = l
b.p = l
c.r = i
c.z = i
c.v = i
c.y = l
m.q = a
assert a.p.x.q.x.x.q.x.x.q.txt == "a"