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

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

class C:
    def __init__(self, txt: str):
        self.v: C = None
        self.s: C = None
        self.u: C = None
        self.txt = txt

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

c.y = f
c.p = f
j.x = h
j.v = i
h.v = a
h.s = a
h.u = a
n.x = i
n.v = i
g.y = c
g.p = k
a.v = h
a.s = h
a.u = i
i.v = h
i.s = a
i.u = a
k.y = c
k.p = c
m.x = i
m.v = a
f.y = k
f.p = k
assert k.p.y.p.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.p: A = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.v: C = None
        self.s: C = None
        self.u: C = None
        self.txt = txt

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

c.y = f
c.p = f
j.x = h
j.v = i
h.v = a
h.s = a
h.u = a
n.x = i
n.v = i
g.y = c
g.p = k
a.v = h
a.s = h
a.u = i
i.v = h
i.s = a
i.u = a
k.y = c
k.p = c
m.x = i
m.v = a
f.y = k
f.p = k
assert k.p.y.p.txt == "k"