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

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

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

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

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

c.w = a
c.r = a
c.v = g
m.t = g
a.u = c
a.z = c
g.x = a
g.v = a
assert m.t.v.z.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.v: D = None
        self.r: C = None
        self.txt = txt

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

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

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

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

c.w = a
c.r = a
c.v = g
m.t = g
a.u = c
a.z = c
g.x = a
g.v = a
assert m.t.v.z.txt == "c"