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

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

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

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

d = A("d")
i = B("i")
n = C("n")
g = D("g")
c = D("c")
e = B("e")
l = B("l")

d.o = e
i.w = e
n.t = g
n.r = g
n.x = c
g.z = n
c.z = n
e.w = i
l.w = e
assert g.z.t.z.r.z.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

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

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

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

d = A("d")
i = B("i")
n = C("n")
g = D("g")
c = D("c")
e = B("e")
l = B("l")

d.o = e
i.w = e
n.t = g
n.r = g
n.x = c
g.z = n
c.z = n
e.w = i
l.w = e
assert g.z.t.z.r.z.txt == "n"