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

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

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

b = A("b")
m = B("m")
j = C("j")

b.s = m
b.o = m
b.v = j
m.y = j
m.x = j
j.q = m
assert m.x.q.y.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.v: C = None
        self.o: B = None
        self.txt = txt

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

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

b = A("b")
m = B("m")
j = C("j")

b.s = m
b.o = m
b.v = j
m.y = j
m.x = j
j.q = m
assert m.x.q.y.txt == "j"