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

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

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

k = A("k")
f = B("f")
d = C("d")
g = A("g")
c = C("c")
e = C("e")
j = C("j")
a = B("a")
n = C("n")
b = A("b")

k.z = a
f.p = d
f.x = b
d.y = j
g.z = a
c.y = d
e.y = c
j.y = c
a.p = c
a.x = k
n.y = c
b.z = a
assert j.y.y.y.y.y.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

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

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

k = A("k")
f = B("f")
d = C("d")
g = A("g")
c = C("c")
e = C("e")
j = C("j")
a = B("a")
n = C("n")
b = A("b")

k.z = a
f.p = d
f.x = b
d.y = j
g.z = a
c.y = d
e.y = c
j.y = c
a.p = c
a.x = k
n.y = c
b.z = a
assert j.y.y.y.y.y.y.y.y.y.txt == "j"