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

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

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

n = A("n")
c = B("c")
k = C("k")
h = A("h")
b = A("b")
j = B("j")
d = A("d")

n.r = k
n.p = k
n.y = j
c.s = j
c.y = k
c.p = n
k.w = j
h.r = k
h.p = k
h.y = j
b.r = k
b.p = k
b.y = c
j.s = c
j.y = k
j.p = d
d.r = k
d.p = k
d.y = c
assert j.y.w.s.p.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.y: B = None
        self.p: C = None
        self.txt = txt

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

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

n = A("n")
c = B("c")
k = C("k")
h = A("h")
b = A("b")
j = B("j")
d = A("d")

n.r = k
n.p = k
n.y = j
c.s = j
c.y = k
c.p = n
k.w = j
h.r = k
h.p = k
h.y = j
b.r = k
b.p = k
b.y = c
j.s = c
j.y = k
j.p = d
d.r = k
d.p = k
d.y = c
assert j.y.w.s.p.txt == "n"