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

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

n = A("n")
l = B("l")
e = B("e")
h = A("h")

n.v = h
n.x = h
l.y = h
l.t = n
e.y = n
e.t = h
h.v = n
h.x = n
assert e.t.x.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.x: A = None
        self.txt = txt

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

n = A("n")
l = B("l")
e = B("e")
h = A("h")

n.v = h
n.x = h
l.y = h
l.t = n
e.y = n
e.t = h
h.v = n
h.x = n
assert e.t.x.v.v.txt == "n"