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

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

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

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

i.o = k
i.q = d
i.y = a
d.w = i
a.q = f
k.o = i
k.q = f
k.y = a
f.w = i
assert i.y.q.w.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.q: B = None
        self.y: C = None
        self.txt = txt

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

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

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

i.o = k
i.q = d
i.y = a
d.w = i
a.q = f
k.o = i
k.q = f
k.y = a
f.w = i
assert i.y.q.w.txt == "i"