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

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

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

j = A("j")
c = B("c")
h = C("h")

j.t = h
c.v = j
c.w = h
c.u = h
h.v = j
assert c.w.v.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

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

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

j = A("j")
c = B("c")
h = C("h")

j.t = h
c.v = j
c.w = h
c.u = h
h.v = j
assert c.w.v.t.txt == "h"