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

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

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

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

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

c.y = l
c.z = l
c.p = l
c.w = n
n.o = g
n.p = l
l.w = n
g.z = c
g.o = c
g.r = l
assert c.p.w.o.r.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.z: C = None
        self.p: C = None
        self.w: B = None
        self.txt = txt

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

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

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

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

c.y = l
c.z = l
c.p = l
c.w = n
n.o = g
n.p = l
l.w = n
g.z = c
g.o = c
g.r = l
assert c.p.w.o.r.txt == "l"