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

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

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

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

a = A("a")
b = B("b")
d = C("d")
i = D("i")
j = A("j")
f = C("f")
n = C("n")
k = D("k")

a.u = b
a.o = k
b.u = n
b.o = k
d.p = b
d.z = n
d.t = k
d.u = i
i.r = j
j.u = b
j.o = k
f.p = b
f.z = n
f.t = i
f.u = k
n.p = b
n.z = d
n.t = k
n.u = i
k.r = a
assert i.r.u.o.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.o: D = None
        self.txt = txt

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

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

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

a = A("a")
b = B("b")
d = C("d")
i = D("i")
j = A("j")
f = C("f")
n = C("n")
k = D("k")

a.u = b
a.o = k
b.u = n
b.o = k
d.p = b
d.z = n
d.t = k
d.u = i
i.r = j
j.u = b
j.o = k
f.p = b
f.z = n
f.t = i
f.u = k
n.p = b
n.z = d
n.t = k
n.u = i
k.r = a
assert i.r.u.o.txt == "k"