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

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

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

f = A("f")
e = B("e")
d = C("d")
h = B("h")
b = B("b")
l = B("l")
n = A("n")

f.z = e
e.x = h
e.v = d
d.x = f
h.x = b
h.v = d
b.x = e
b.v = d
l.x = b
l.v = d
n.z = e
assert e.x.x.v.x.z.v.x.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

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

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

f = A("f")
e = B("e")
d = C("d")
h = B("h")
b = B("b")
l = B("l")
n = A("n")

f.z = e
e.x = h
e.v = d
d.x = f
h.x = b
h.v = d
b.x = e
b.v = d
l.x = b
l.v = d
n.z = e
assert e.x.x.v.x.z.v.x.txt == "f"