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

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

e = A("e")
m = B("m")
j = B("j")
h = A("h")

e.v = h
m.t = j
m.x = h
j.t = m
j.x = e
h.v = e
assert e.v.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.t: B = None
        self.x: A = None
        self.txt = txt

e = A("e")
m = B("m")
j = B("j")
h = A("h")

e.v = h
m.t = j
m.x = h
j.t = m
j.x = e
h.v = e
assert e.v.v.v.v.txt == "e"