class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.q: B = None
        self.o: B = None
        self.txt = txt

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

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

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

d.y = a
d.q = a
d.o = a
a.s = d
f.x = d
f.t = a
assert f.x.o.s.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.q: B = None
        self.o: B = None
        self.txt = txt

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

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

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

d.y = a
d.q = a
d.o = a
a.s = d
f.x = d
f.t = a
assert f.x.o.s.txt == "d"