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

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

a = A("a")
e = B("e")
b = B("b")
h = B("h")
n = B("n")
j = A("j")

a.t = h
a.y = j
e.v = h
e.t = j
b.v = n
b.t = j
h.v = n
h.t = a
n.v = b
n.t = j
j.t = b
j.y = a
assert j.t.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.y: A = None
        self.txt = txt

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

a = A("a")
e = B("e")
b = B("b")
h = B("h")
n = B("n")
j = A("j")

a.t = h
a.y = j
e.v = h
e.t = j
b.v = n
b.t = j
h.v = n
h.t = a
n.v = b
n.t = j
j.t = b
j.y = a
assert j.t.v.v.txt == "b"