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

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

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

k = A("k")
l = B("l")
i = C("i")
a = B("a")
d = C("d")
n = C("n")
b = C("b")
g = B("g")
j = C("j")
c = C("c")

k.r = a
k.o = j
l.y = k
i.r = k
i.p = g
a.y = k
d.r = k
d.p = a
n.r = k
n.p = a
b.r = k
b.p = g
g.y = k
j.r = k
j.p = l
c.r = k
c.p = l
assert b.r.o.p.y.o.p.y.o.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.o: C = None
        self.txt = txt

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

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

k = A("k")
l = B("l")
i = C("i")
a = B("a")
d = C("d")
n = C("n")
b = C("b")
g = B("g")
j = C("j")
c = C("c")

k.r = a
k.o = j
l.y = k
i.r = k
i.p = g
a.y = k
d.r = k
d.p = a
n.r = k
n.p = a
b.r = k
b.p = g
g.y = k
j.r = k
j.p = l
c.r = k
c.p = l
assert b.r.o.p.y.o.p.y.o.txt == "j"