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

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

class C:
    def __init__(self, txt: str):
        self.v: D = None
        self.q: B = None
        self.txt = txt

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

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

k = A("k")
g = B("g")
b = C("b")
d = D("d")
i = E("i")
e = E("e")
n = D("n")

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

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

class C:
    def __init__(self, txt: str):
        self.v: D = None
        self.q: B = None
        self.txt = txt

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

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

k = A("k")
g = B("g")
b = C("b")
d = D("d")
i = E("i")
e = E("e")
n = D("n")

k.w = d
k.r = b
g.s = n
b.v = d
b.q = g
d.p = k
i.z = b
i.y = d
i.x = d
e.z = b
e.y = d
e.x = n
n.p = k
assert g.s.p.w.txt == "d"