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

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

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

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

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

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

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

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

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