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

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

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

h = A("h")
j = B("j")
k = C("k")
l = B("l")

h.r = k
j.z = l
k.p = h
k.y = h
l.z = j
assert h.r.y.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

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

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

h = A("h")
j = B("j")
k = C("k")
l = B("l")

h.r = k
j.z = l
k.p = h
k.y = h
l.z = j
assert h.r.y.r.txt == "k"