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

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

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

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

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

g.w = l
g.u = e
c.z = g
c.p = g
c.o = g
e.q = c
e.o = c
e.y = g
l.t = i
l.s = g
l.y = c
i.t = l
i.s = g
i.y = c
assert g.w.s.u.y.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.u: C = None
        self.txt = txt

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

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

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

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

g.w = l
g.u = e
c.z = g
c.p = g
c.o = g
e.q = c
e.o = c
e.y = g
l.t = i
l.s = g
l.y = c
i.t = l
i.s = g
i.y = c
assert g.w.s.u.y.txt == "g"