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

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

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

l = A("l")
c = B("c")
d = C("d")
n = B("n")

l.u = n
l.x = n
c.p = n
d.s = l
n.p = c
assert n.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.x: B = None
        self.txt = txt

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

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

l = A("l")
c = B("c")
d = C("d")
n = B("n")

l.u = n
l.x = n
c.p = n
d.s = l
n.p = c
assert n.p.p.p.txt == "c"