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

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

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

class D:
    def __init__(self, txt: str):
        self.u: A = None
        self.w: A = None
        self.t: A = None
        self.q: A = None
        self.txt = txt

a = A("a")
b = B("b")
m = C("m")
n = D("n")

a.p = n
a.y = n
a.s = n
a.v = n
b.w = a
m.z = n
m.s = a
m.v = a
n.u = a
n.w = a
n.t = a
n.q = a
assert m.z.q.v.u.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.y: D = None
        self.s: D = None
        self.v: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.u: A = None
        self.w: A = None
        self.t: A = None
        self.q: A = None
        self.txt = txt

a = A("a")
b = B("b")
m = C("m")
n = D("n")

a.p = n
a.y = n
a.s = n
a.v = n
b.w = a
m.z = n
m.s = a
m.v = a
n.u = a
n.w = a
n.t = a
n.q = a
assert m.z.q.v.u.txt == "a"