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

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

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

h.v = e
h.t = d
j.x = e
e.v = h
e.t = d
d.x = h
assert j.x.t.x.t.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.t: B = None
        self.txt = txt

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

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

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