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

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

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

j = A("j")
n = B("n")
g = C("g")
i = A("i")

j.q = i
j.y = g
j.o = g
n.u = i
n.q = j
g.p = n
g.t = i
i.q = j
i.y = g
i.o = g
assert i.q.o.t.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.y: C = None
        self.o: C = None
        self.txt = txt

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

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

j = A("j")
n = B("n")
g = C("g")
i = A("i")

j.q = i
j.y = g
j.o = g
n.u = i
n.q = j
g.p = n
g.t = i
i.q = j
i.y = g
i.o = g
assert i.q.o.t.txt == "i"