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

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

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

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

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

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

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

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

c.r = g
c.y = g
c.q = j
g.r = j
g.t = j
j.t = c
j.z = g
assert g.t.z.r.txt == "j"