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

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

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

l = A("l")
n = B("n")
h = C("h")
b = B("b")

l.r = n
l.x = n
l.u = b
n.s = b
h.q = l
b.s = n
assert n.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.u: B = None
        self.x: B = None
        self.txt = txt

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

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

l = A("l")
n = B("n")
h = C("h")
b = B("b")

l.r = n
l.x = n
l.u = b
n.s = b
h.q = l
b.s = n
assert n.s.s.s.txt == "b"