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

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

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

j = A("j")
f = B("f")
m = C("m")

j.v = f
j.r = m
j.q = m
f.u = m
f.x = j
m.q = f
m.t = f
m.v = j
assert m.v.v.u.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.r: C = None
        self.q: C = None
        self.txt = txt

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

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

j = A("j")
f = B("f")
m = C("m")

j.v = f
j.r = m
j.q = m
f.u = m
f.x = j
m.q = f
m.t = f
m.v = j
assert m.v.v.u.txt == "m"