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

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

f = A("f")
g = B("g")
h = A("h")
l = A("l")
m = B("m")
k = A("k")
e = B("e")
b = A("b")
j = B("j")

f.z = b
f.v = h
g.t = b
h.z = f
h.v = f
l.z = f
l.v = f
m.t = k
k.z = b
k.v = l
e.t = h
b.z = l
b.v = f
j.t = b
assert l.z.v.z.v.z.z.v.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.v: A = None
        self.txt = txt

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

f = A("f")
g = B("g")
h = A("h")
l = A("l")
m = B("m")
k = A("k")
e = B("e")
b = A("b")
j = B("j")

f.z = b
f.v = h
g.t = b
h.z = f
h.v = f
l.z = f
l.v = f
m.t = k
k.z = b
k.v = l
e.t = h
b.z = l
b.v = f
j.t = b
assert l.z.v.z.v.z.z.v.txt == "f"