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

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

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

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

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

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

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

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

f.w = e
f.r = d
k.u = d
k.r = d
k.z = h
d.o = c
d.s = h
d.r = e
i.u = d
i.r = d
i.z = h
h.o = c
h.s = d
h.r = f
n.u = d
n.r = d
n.z = h
e.w = f
e.r = d
j.u = h
j.z = h
j.r = d
c.u = h
c.r = h
c.z = h
a.u = h
a.r = h
a.z = h
assert f.w.r.r.w.r.s.r.w.w.w.txt == "e"