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

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

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

c = A("c")
l = B("l")
b = C("b")
i = A("i")
k = C("k")

c.p = l
l.u = c
l.r = i
b.o = c
i.p = l
k.o = c
assert k.o.p.u.p.r.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

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

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

c = A("c")
l = B("l")
b = C("b")
i = A("i")
k = C("k")

c.p = l
l.u = c
l.r = i
b.o = c
i.p = l
k.o = c
assert k.o.p.u.p.r.txt == "i"