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

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

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

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

c = A("c")
m = B("m")
f = C("f")
b = D("b")

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

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

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

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

c = A("c")
m = B("m")
f = C("f")
b = D("b")

c.v = b
c.u = b
c.q = m
m.v = f
m.w = b
m.z = b
m.y = c
f.p = m
f.s = b
f.q = c
b.q = m
b.u = f
assert b.u.s.u.q.txt == "c"