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

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

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

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

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

a.t = m
a.x = b
a.q = b
a.r = i
j.y = m
j.z = m
h.s = m
b.x = i
b.v = i
b.u = a
b.p = h
n.y = m
n.z = j
m.y = n
m.z = j
i.x = b
i.v = b
i.u = a
i.p = h
assert i.p.s.y.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.x: D = None
        self.r: D = None
        self.q: D = None
        self.txt = txt

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

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

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

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

a.t = m
a.x = b
a.q = b
a.r = i
j.y = m
j.z = m
h.s = m
b.x = i
b.v = i
b.u = a
b.p = h
n.y = m
n.z = j
m.y = n
m.z = j
i.x = b
i.v = b
i.u = a
i.p = h
assert i.p.s.y.z.z.txt == "m"