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

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

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

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

c = A("c")
f = B("f")
i = C("i")
g = D("g")

c.v = i
c.q = i
c.x = g
f.s = c
i.x = f
i.z = c
i.p = g
g.w = i
g.y = i
g.z = f
assert c.q.p.z.s.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.x: D = None
        self.q: C = None
        self.txt = txt

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

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

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

c = A("c")
f = B("f")
i = C("i")
g = D("g")

c.v = i
c.q = i
c.x = g
f.s = c
i.x = f
i.z = c
i.p = g
g.w = i
g.y = i
g.z = f
assert c.q.p.z.s.txt == "c"