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

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

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

c = A("c")
b = B("b")
a = C("a")

c.y = b
c.t = b
b.y = c
b.x = c
b.q = a
a.r = b
assert a.r.q.r.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.t: B = None
        self.txt = txt

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

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

c = A("c")
b = B("b")
a = C("a")

c.y = b
c.t = b
b.y = c
b.x = c
b.q = a
a.r = b
assert a.r.q.r.txt == "b"