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

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

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

a = A("a")
l = B("l")
d = C("d")

a.r = d
l.u = d
l.x = d
d.x = l
d.p = l
d.o = a
assert l.x.o.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

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

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

a = A("a")
l = B("l")
d = C("d")

a.r = d
l.u = d
l.x = d
d.x = l
d.p = l
d.o = a
assert l.x.o.r.txt == "d"