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

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

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

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

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

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

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

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

h.w = j
h.p = j
a.w = j
j.r = h
j.u = a
assert j.u.w.u.txt == "a"