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

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

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

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

m = A("m")
k = B("k")
g = C("g")
d = D("d")
i = A("i")
e = C("e")

m.w = e
m.q = g
m.p = d
k.y = g
g.z = e
g.u = k
d.p = m
d.x = g
d.y = i
i.w = g
i.q = e
i.p = d
e.z = g
e.u = k
assert g.z.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.q: C = None
        self.p: D = None
        self.txt = txt

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

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

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

m = A("m")
k = B("k")
g = C("g")
d = D("d")
i = A("i")
e = C("e")

m.w = e
m.q = g
m.p = d
k.y = g
g.z = e
g.u = k
d.p = m
d.x = g
d.y = i
i.w = g
i.q = e
i.p = d
e.z = g
e.u = k
assert g.z.z.z.txt == "e"