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

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

class C:
    def __init__(self, txt: str):
        self.r: D = None
        self.w: A = None
        self.txt = txt

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

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

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

a.z = h
a.t = h
a.u = b
a.s = b
d.x = h
d.y = m
d.r = m
h.r = k
h.w = m
g.y = k
g.t = b
b.q = h
m.z = h
m.t = h
m.u = b
m.s = b
l.z = h
l.t = h
l.u = b
l.s = b
k.y = g
k.t = b
assert d.x.w.u.q.r.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.u: E = None
        self.t: C = None
        self.s: E = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.r: D = None
        self.w: A = None
        self.txt = txt

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

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

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

a.z = h
a.t = h
a.u = b
a.s = b
d.x = h
d.y = m
d.r = m
h.r = k
h.w = m
g.y = k
g.t = b
b.q = h
m.z = h
m.t = h
m.u = b
m.s = b
l.z = h
l.t = h
l.u = b
l.s = b
k.y = g
k.t = b
assert d.x.w.u.q.r.txt == "k"