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

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

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

l = A("l")
c = B("c")
f = C("f")
i = A("i")
g = B("g")

l.q = i
l.x = g
l.s = f
c.x = l
c.u = l
c.q = f
f.w = g
f.o = g
i.q = l
i.x = g
i.s = f
g.x = l
g.u = l
g.q = f
assert c.u.q.s.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.x: B = None
        self.s: C = None
        self.txt = txt

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

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

l = A("l")
c = B("c")
f = C("f")
i = A("i")
g = B("g")

l.q = i
l.x = g
l.s = f
c.x = l
c.u = l
c.q = f
f.w = g
f.o = g
i.q = l
i.x = g
i.s = f
g.x = l
g.u = l
g.q = f
assert c.u.q.s.txt == "f"