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

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

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

g = A("g")
k = B("k")
i = C("i")
n = B("n")
d = A("d")

g.y = k
g.r = d
g.t = i
k.z = d
i.w = d
i.v = n
n.z = g
d.y = k
d.r = g
d.t = i
assert d.t.v.z.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.r: A = None
        self.t: C = None
        self.txt = txt

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

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

g = A("g")
k = B("k")
i = C("i")
n = B("n")
d = A("d")

g.y = k
g.r = d
g.t = i
k.z = d
i.w = d
i.v = n
n.z = g
d.y = k
d.r = g
d.t = i
assert d.t.v.z.y.txt == "k"