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

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

d = A("d")
m = B("m")
i = B("i")
f = B("f")
k = B("k")
l = B("l")
e = A("e")
a = A("a")
j = B("j")

d.x = a
d.v = e
m.x = e
i.x = d
f.x = e
k.x = d
l.x = e
e.x = d
e.v = d
a.x = d
a.v = d
j.x = e
assert j.x.x.x.x.v.x.v.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.v: A = None
        self.txt = txt

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

d = A("d")
m = B("m")
i = B("i")
f = B("f")
k = B("k")
l = B("l")
e = A("e")
a = A("a")
j = B("j")

d.x = a
d.v = e
m.x = e
i.x = d
f.x = e
k.x = d
l.x = e
e.x = d
e.v = d
a.x = d
a.v = d
j.x = e
assert j.x.x.x.x.v.x.v.x.txt == "d"