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

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

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

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

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

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

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