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

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

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

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

i.z = g
e.v = g
e.u = n
k.y = g
k.u = g
n.z = g
g.v = e
g.u = i
assert g.v.u.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

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

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

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

i.z = g
e.v = g
e.u = n
k.y = g
k.u = g
n.z = g
g.v = e
g.u = i
assert g.v.u.z.txt == "g"