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

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

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

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

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

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

g.v = e
i.u = g
i.x = g
e.v = g
assert e.v.v.v.txt == "g"