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

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

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

e = A("e")
h = B("h")
f = C("f")

e.q = h
e.r = h
h.u = f
h.r = e
f.u = h
f.q = e
assert e.r.u.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.r: B = None
        self.txt = txt

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

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

e = A("e")
h = B("h")
f = C("f")

e.q = h
e.r = h
h.u = f
h.r = e
f.u = h
f.q = e
assert e.r.u.q.txt == "e"