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

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

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

c = A("c")
m = B("m")
g = C("g")
h = B("h")

c.w = h
c.q = h
c.o = m
m.x = c
m.t = h
g.q = m
h.x = c
h.t = m
assert g.q.t.x.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.q: B = None
        self.o: B = None
        self.txt = txt

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

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

c = A("c")
m = B("m")
g = C("g")
h = B("h")

c.w = h
c.q = h
c.o = m
m.x = c
m.t = h
g.q = m
h.x = c
h.t = m
assert g.q.t.x.txt == "c"