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

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

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

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

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

k.u = c
k.o = i
b.u = a
b.r = k
b.o = n
n.y = m
n.s = j
g.x = a
a.u = c
a.r = i
a.o = n
m.y = j
m.s = j
f.x = a
c.u = a
c.r = i
c.o = n
j.y = m
j.s = n
i.u = c
i.o = k
assert f.x.o.s.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.o: A = None
        self.txt = txt

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

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

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

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

k.u = c
k.o = i
b.u = a
b.r = k
b.o = n
n.y = m
n.s = j
g.x = a
a.u = c
a.r = i
a.o = n
m.y = j
m.s = j
f.x = a
c.u = a
c.r = i
c.o = n
j.y = m
j.s = n
i.u = c
i.o = k
assert f.x.o.s.txt == "j"