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

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

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

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

n = A("n")
b = B("b")
m = C("m")
l = D("l")
c = D("c")
i = C("i")

n.p = c
n.w = b
n.y = b
b.q = n
b.w = n
m.z = c
l.u = b
l.r = n
c.u = b
c.r = n
i.z = c
assert m.z.u.q.y.w.y.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.w: B = None
        self.y: B = None
        self.txt = txt

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

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

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

n = A("n")
b = B("b")
m = C("m")
l = D("l")
c = D("c")
i = C("i")

n.p = c
n.w = b
n.y = b
b.q = n
b.w = n
m.z = c
l.u = b
l.r = n
c.u = b
c.r = n
i.z = c
assert m.z.u.q.y.w.y.txt == "b"