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

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

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

g = A("g")
i = B("i")
m = C("m")
j = A("j")

g.v = i
g.u = i
i.v = g
i.t = m
i.z = j
m.v = j
m.z = i
j.v = i
j.u = i
assert i.v.u.z.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.u: B = None
        self.txt = txt

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

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

g = A("g")
i = B("i")
m = C("m")
j = A("j")

g.v = i
g.u = i
i.v = g
i.t = m
i.z = j
m.v = j
m.z = i
j.v = i
j.u = i
assert i.v.u.z.v.txt == "i"