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

class B:
    def __init__(self, txt: str):
        self.r: D = None
        self.p: D = 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.z: B = None
        self.w: C = None
        self.txt = txt

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

c = A("c")
d = B("d")
k = C("k")
g = D("g")
i = E("i")
a = B("a")
f = A("f")

c.x = k
c.s = g
d.r = g
d.p = g
k.t = g
g.z = a
g.w = k
i.t = k
i.q = k
i.u = a
i.x = d
a.r = g
a.p = g
f.x = k
f.s = g
assert g.w.t.z.p.w.t.w.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.s: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.r: D = None
        self.p: D = 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.z: B = None
        self.w: C = None
        self.txt = txt

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

c = A("c")
d = B("d")
k = C("k")
g = D("g")
i = E("i")
a = B("a")
f = A("f")

c.x = k
c.s = g
d.r = g
d.p = g
k.t = g
g.z = a
g.w = k
i.t = k
i.q = k
i.u = a
i.x = d
a.r = g
a.p = g
f.x = k
f.s = g
assert g.w.t.z.p.w.t.w.txt == "k"