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

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

i = A("i")
j = B("j")
k = B("k")
e = A("e")
c = B("c")
d = A("d")
h = A("h")

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

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

i = A("i")
j = B("j")
k = B("k")
e = A("e")
c = B("c")
d = A("d")
h = A("h")

i.x = j
j.v = k
j.w = e
k.v = c
k.w = d
e.x = c
c.v = k
c.w = e
d.x = j
h.x = k
assert i.x.v.w.x.v.v.v.txt == "k"