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

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

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

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

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

a.p = f
a.s = f
a.y = f
m.v = d
m.q = f
m.p = a
m.r = a
f.q = n
f.y = a
f.z = d
d.q = a
n.q = f
n.y = a
n.z = d
g.v = d
g.q = f
g.p = a
g.r = a
c.q = a
assert m.q.z.q.s.q.z.q.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.s: C = None
        self.y: C = None
        self.txt = txt

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

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

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

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

a.p = f
a.s = f
a.y = f
m.v = d
m.q = f
m.p = a
m.r = a
f.q = n
f.y = a
f.z = d
d.q = a
n.q = f
n.y = a
n.z = d
g.v = d
g.q = f
g.p = a
g.r = a
c.q = a
assert m.q.z.q.s.q.z.q.txt == "a"