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

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

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

e = A("e")
j = B("j")
g = C("g")

e.q = g
e.y = j
j.y = g
j.q = e
g.x = e
g.z = e
g.y = j
assert g.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.y: B = None
        self.txt = txt

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

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

e = A("e")
j = B("j")
g = C("g")

e.q = g
e.y = j
j.y = g
j.q = e
g.x = e
g.z = e
g.y = j
assert g.y.y.y.txt == "j"