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

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

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

f = A("f")
k = B("k")
e = C("e")
l = B("l")
n = A("n")
h = A("h")
g = B("g")
c = C("c")
j = A("j")

f.y = g
k.p = n
e.x = n
e.o = f
e.s = k
l.p = h
n.y = g
h.y = l
g.p = n
c.x = j
c.o = f
c.s = l
j.y = l
assert k.p.y.p.y.p.y.p.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

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

f = A("f")
k = B("k")
e = C("e")
l = B("l")
n = A("n")
h = A("h")
g = B("g")
c = C("c")
j = A("j")

f.y = g
k.p = n
e.x = n
e.o = f
e.s = k
l.p = h
n.y = g
h.y = l
g.p = n
c.x = j
c.o = f
c.s = l
j.y = l
assert k.p.y.p.y.p.y.p.y.txt == "g"