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

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

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

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

g.t = j
g.p = a
g.w = a
a.r = j
a.u = j
a.v = g
j.r = a
assert g.w.v.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.p: B = None
        self.w: B = None
        self.txt = txt

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

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

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

g.t = j
g.p = a
g.w = a
a.r = j
a.u = j
a.v = g
j.r = a
assert g.w.v.t.txt == "j"