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

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

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

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

class E:
    def __init__(self, txt: str):
        self.s: D = None
        self.z: A = None
        self.x: A = None
        self.w: D = None
        self.txt = txt

n = A("n")
k = B("k")
f = C("f")
c = D("c")
g = E("g")
m = B("m")
e = C("e")

n.q = e
n.w = g
n.r = g
k.x = n
f.t = c
c.p = k
c.r = k
c.y = n
c.z = n
g.s = c
g.w = c
g.z = n
g.x = n
m.x = n
e.t = c
assert e.t.p.x.q.t.y.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.w: E = None
        self.r: E = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.s: D = None
        self.z: A = None
        self.x: A = None
        self.w: D = None
        self.txt = txt

n = A("n")
k = B("k")
f = C("f")
c = D("c")
g = E("g")
m = B("m")
e = C("e")

n.q = e
n.w = g
n.r = g
k.x = n
f.t = c
c.p = k
c.r = k
c.y = n
c.z = n
g.s = c
g.w = c
g.z = n
g.x = n
m.x = n
e.t = c
assert e.t.p.x.q.t.y.txt == "n"