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

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

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

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

h.r = n
h.o = i
k.p = n
n.w = k
n.r = k
n.s = k
m.p = n
i.r = n
i.o = c
c.r = n
c.o = i
j.r = n
j.o = c
assert i.o.r.s.p.r.p.w.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.o: A = None
        self.txt = txt

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

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

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

h.r = n
h.o = i
k.p = n
n.w = k
n.r = k
n.s = k
m.p = n
i.r = n
i.o = c
c.r = n
c.o = i
j.r = n
j.o = c
assert i.o.r.s.p.r.p.w.txt == "k"