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

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

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

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

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

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

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

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

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

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

c.s = m
c.q = g
c.z = g
c.w = n
n.v = g
g.v = m
g.y = c
g.p = c
m.o = g
m.z = c
m.r = n
assert n.v.p.z.y.txt == "c"