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

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

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

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

m = A("m")
n = B("n")
k = C("k")
j = D("j")
i = D("i")
f = B("f")

m.q = f
n.p = k
n.z = k
k.t = f
k.w = m
k.v = j
j.r = i
j.u = m
i.r = j
i.u = m
f.p = k
f.z = k
assert m.q.z.v.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.txt = txt

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

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

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

m = A("m")
n = B("n")
k = C("k")
j = D("j")
i = D("i")
f = B("f")

m.q = f
n.p = k
n.z = k
k.t = f
k.w = m
k.v = j
j.r = i
j.u = m
i.r = j
i.u = m
f.p = k
f.z = k
assert m.q.z.v.txt == "j"