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

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

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

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

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

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

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

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

d.p = k
g.x = j
k.u = f
k.q = j
k.y = d
f.x = k
h.x = c
c.u = f
c.q = j
c.y = a
j.u = g
j.q = k
j.y = d
a.p = k
e.p = c
n.p = k
assert c.u.x.y.p.y.p.q.y.p.txt == "k"