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

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

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

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

k = A("k")
n = B("n")
m = C("m")
a = D("a")
b = B("b")
i = A("i")
e = D("e")
f = A("f")
j = A("j")
l = C("l")

k.z = l
k.x = l
n.r = b
n.o = l
m.r = f
a.o = k
a.z = j
a.u = b
b.r = n
b.o = l
i.z = m
i.x = m
e.o = i
e.z = j
e.u = b
f.z = m
f.x = m
j.z = m
j.x = m
l.r = i
assert e.u.r.r.r.o.r.x.r.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.x: C = None
        self.txt = txt

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

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

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

k = A("k")
n = B("n")
m = C("m")
a = D("a")
b = B("b")
i = A("i")
e = D("e")
f = A("f")
j = A("j")
l = C("l")

k.z = l
k.x = l
n.r = b
n.o = l
m.r = f
a.o = k
a.z = j
a.u = b
b.r = n
b.o = l
i.z = m
i.x = m
e.o = i
e.z = j
e.u = b
f.z = m
f.x = m
j.z = m
j.x = m
l.r = i
assert e.u.r.r.r.o.r.x.r.txt == "f"