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

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

c = A("c")
f = B("f")
h = A("h")
b = A("b")
d = B("d")
l = B("l")
j = B("j")
k = A("k")

c.v = h
f.y = b
f.x = c
h.v = k
b.v = c
d.y = h
d.x = c
l.y = k
l.x = k
j.y = b
j.x = b
k.v = b
assert f.x.v.v.v.v.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.txt = txt

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

c = A("c")
f = B("f")
h = A("h")
b = A("b")
d = B("d")
l = B("l")
j = B("j")
k = A("k")

c.v = h
f.y = b
f.x = c
h.v = k
b.v = c
d.y = h
d.x = c
l.y = k
l.x = k
j.y = b
j.x = b
k.v = b
assert f.x.v.v.v.v.v.v.v.txt == "b"