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

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

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

d = A("d")
e = B("e")
h = C("h")
a = C("a")

d.t = a
e.o = a
e.w = d
h.q = a
h.v = a
h.y = d
a.q = h
a.v = h
a.y = d
assert h.y.t.y.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

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

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

d = A("d")
e = B("e")
h = C("h")
a = C("a")

d.t = a
e.o = a
e.w = d
h.q = a
h.v = a
h.y = d
a.q = h
a.v = h
a.y = d
assert h.y.t.y.txt == "d"