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

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

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

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

c = A("c")
b = B("b")
g = C("g")
e = D("e")
m = B("m")

c.z = g
c.p = g
c.v = g
c.y = g
b.y = m
g.q = b
g.v = b
e.q = g
e.y = m
m.y = b
assert c.v.q.y.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.p: C = None
        self.v: C = None
        self.y: C = None
        self.txt = txt

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

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

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

c = A("c")
b = B("b")
g = C("g")
e = D("e")
m = B("m")

c.z = g
c.p = g
c.v = g
c.y = g
b.y = m
g.q = b
g.v = b
e.q = g
e.y = m
m.y = b
assert c.v.q.y.txt == "m"