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

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

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

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

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

f.s = k
f.u = k
l.o = k
l.v = h
l.p = h
i.x = n
i.u = d
a.z = h
a.r = e
a.o = n
d.s = k
d.u = j
n.x = i
n.u = j
j.s = f
j.u = f
k.s = d
k.u = d
e.o = f
e.v = h
e.p = h
h.z = a
h.r = e
h.o = i
assert k.u.u.s.s.s.s.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.u: A = None
        self.txt = txt

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

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

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

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

f.s = k
f.u = k
l.o = k
l.v = h
l.p = h
i.x = n
i.u = d
a.z = h
a.r = e
a.o = n
d.s = k
d.u = j
n.x = i
n.u = j
j.s = f
j.u = f
k.s = d
k.u = d
e.o = f
e.v = h
e.p = h
h.z = a
h.r = e
h.o = i
assert k.u.u.s.s.s.s.u.u.u.txt == "f"