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

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

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

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

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

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

e.v = d
d.s = e
d.v = i
j.v = d
i.s = j
i.v = d
assert e.v.v.v.txt == "d"