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

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

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

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

h.y = n
h.o = n
i.u = j
i.w = d
i.p = d
f.z = h
a.u = h
a.w = i
a.p = d
d.u = n
d.w = a
d.p = i
j.y = n
j.o = h
n.y = j
n.o = h
assert j.o.y.o.y.o.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.o: A = None
        self.txt = txt

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

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

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

h.y = n
h.o = n
i.u = j
i.w = d
i.p = d
f.z = h
a.u = h
a.w = i
a.p = d
d.u = n
d.w = a
d.p = i
j.y = n
j.o = h
n.y = j
n.o = h
assert j.o.y.o.y.o.txt == "h"