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

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

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

b = A("b")
f = B("f")
c = C("c")
j = A("j")
k = C("k")

b.x = j
b.w = j
b.o = c
f.o = j
c.o = f
c.p = f
c.s = j
j.x = b
j.w = b
j.o = c
k.o = f
k.p = f
k.s = b
assert f.o.w.o.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.o: C = None
        self.w: A = None
        self.txt = txt

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

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

b = A("b")
f = B("f")
c = C("c")
j = A("j")
k = C("k")

b.x = j
b.w = j
b.o = c
f.o = j
c.o = f
c.p = f
c.s = j
j.x = b
j.w = b
j.o = c
k.o = f
k.p = f
k.s = b
assert f.o.w.o.txt == "c"