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

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

c = A("c")
a = B("a")
l = B("l")
h = B("h")
j = A("j")
e = B("e")
n = A("n")
f = A("f")
i = B("i")

c.v = e
a.y = h
a.x = i
l.y = h
l.x = e
h.y = i
h.x = e
j.v = l
e.y = h
e.x = l
n.v = a
f.v = i
i.y = l
i.x = l
assert i.y.y.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.txt = txt

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

c = A("c")
a = B("a")
l = B("l")
h = B("h")
j = A("j")
e = B("e")
n = A("n")
f = A("f")
i = B("i")

c.v = e
a.y = h
a.x = i
l.y = h
l.x = e
h.y = i
h.x = e
j.v = l
e.y = h
e.x = l
n.v = a
f.v = i
i.y = l
i.x = l
assert i.y.y.x.x.txt == "l"