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

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

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

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

j = A("j")
g = B("g")
n = C("n")
f = D("f")
l = B("l")
m = A("m")
i = C("i")
d = D("d")
b = D("b")

j.t = b
j.z = m
j.x = l
g.r = m
n.z = j
f.q = b
f.o = d
f.z = i
l.r = m
m.t = d
m.z = j
m.x = g
i.z = m
d.q = b
d.o = f
d.z = i
b.q = f
b.o = d
b.z = i
assert d.o.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.t: D = None
        self.z: A = None
        self.x: B = None
        self.txt = txt

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

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

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

j = A("j")
g = B("g")
n = C("n")
f = D("f")
l = B("l")
m = A("m")
i = C("i")
d = D("d")
b = D("b")

j.t = b
j.z = m
j.x = l
g.r = m
n.z = j
f.q = b
f.o = d
f.z = i
l.r = m
m.t = d
m.z = j
m.x = g
i.z = m
d.q = b
d.o = f
d.z = i
b.q = f
b.o = d
b.z = i
assert d.o.z.z.txt == "m"