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

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

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

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

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

j.u = n
j.y = n
j.z = n
j.r = c
a.t = i
n.z = j
n.x = i
i.q = j
m.u = n
m.y = n
m.z = n
m.r = c
c.t = i
assert n.z.r.t.q.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.y: C = None
        self.z: C = None
        self.r: B = None
        self.txt = txt

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

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

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

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

j.u = n
j.y = n
j.z = n
j.r = c
a.t = i
n.z = j
n.x = i
i.q = j
m.u = n
m.y = n
m.z = n
m.r = c
c.t = i
assert n.z.r.t.q.txt == "j"