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

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

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

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

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

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

m.q = f
m.y = e
m.w = e
g.y = m
g.p = k
g.s = f
g.r = f
g.z = d
d.v = h
f.x = m
f.o = m
f.s = m
f.r = d
h.x = g
h.r = g
h.z = e
e.v = h
k.y = m
k.p = g
k.s = f
k.r = f
k.z = e
assert m.q.r.v.r.z.txt == "
class A:
    def __init__(self, txt: str):
        self.q: D = None
        self.y: C = None
        self.w: C = None
        self.txt = txt

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

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

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

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

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

m.q = f
m.y = e
m.w = e
g.y = m
g.p = k
g.s = f
g.r = f
g.z = d
d.v = h
f.x = m
f.o = m
f.s = m
f.r = d
h.x = g
h.r = g
h.z = e
e.v = h
k.y = m
k.p = g
k.s = f
k.r = f
k.z = e
assert m.q.r.v.r.z.txt == "d"