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

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

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

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

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

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

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

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

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

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

m.z = c
n.q = b
n.w = b
n.y = m
j.v = c
j.y = m
j.p = m
j.r = m
c.v = m
c.r = m
c.s = m
c.y = n
b.q = n
b.w = n
b.y = m
a.v = m
a.r = m
a.s = m
a.y = n
assert m.z.y.q.y.z.txt == "c"