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

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

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

m = A("m")
n = B("n")
g = C("g")
h = C("h")
a = A("a")
e = C("e")
f = B("f")
k = A("k")
j = B("j")

m.r = a
m.s = j
m.y = e
n.z = j
n.p = e
g.u = n
g.o = f
h.u = f
h.o = n
a.r = k
a.s = f
a.y = e
e.u = f
e.o = f
f.z = n
f.p = g
k.r = m
k.s = f
k.y = g
j.z = n
j.p = e
assert m.r.y.o.z.p.u.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.s: B = None
        self.y: C = None
        self.txt = txt

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

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

m = A("m")
n = B("n")
g = C("g")
h = C("h")
a = A("a")
e = C("e")
f = B("f")
k = A("k")
j = B("j")

m.r = a
m.s = j
m.y = e
n.z = j
n.p = e
g.u = n
g.o = f
h.u = f
h.o = n
a.r = k
a.s = f
a.y = e
e.u = f
e.o = f
f.z = n
f.p = g
k.r = m
k.s = f
k.y = g
j.z = n
j.p = e
assert m.r.y.o.z.p.u.txt == "f"