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

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

class C:
    def __init__(self, txt: str):
        self.t: D = None
        self.q: E = None
        self.v: A = None
        self.w: A = None
        self.z: B = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.q: B = None
        self.w: B = None
        self.p: C = None
        self.z: E = None
        self.y: B = None
        self.txt = txt

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

d = A("d")
f = B("f")
g = C("g")
h = D("h")
l = E("l")
m = C("m")
e = E("e")

d.y = f
f.r = h
g.t = h
g.q = l
g.v = d
g.w = d
g.z = f
h.q = f
h.w = f
h.y = f
h.p = g
h.z = l
l.q = d
m.t = h
m.q = e
m.v = d
m.w = d
m.z = f
e.q = d
assert f.r.z.q.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.t: D = None
        self.q: E = None
        self.v: A = None
        self.w: A = None
        self.z: B = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.q: B = None
        self.w: B = None
        self.p: C = None
        self.z: E = None
        self.y: B = None
        self.txt = txt

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

d = A("d")
f = B("f")
g = C("g")
h = D("h")
l = E("l")
m = C("m")
e = E("e")

d.y = f
f.r = h
g.t = h
g.q = l
g.v = d
g.w = d
g.z = f
h.q = f
h.w = f
h.y = f
h.p = g
h.z = l
l.q = d
m.t = h
m.q = e
m.v = d
m.w = d
m.z = f
e.q = d
assert f.r.z.q.txt == "d"