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

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

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

j = A("j")
i = B("i")
a = C("a")
h = C("h")
d = C("d")
b = A("b")

j.v = b
i.z = b
a.v = j
a.o = d
h.v = j
h.o = a
d.v = b
d.o = h
b.v = j
assert h.o.o.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.z: A = None
        self.txt = txt

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

j = A("j")
i = B("i")
a = C("a")
h = C("h")
d = C("d")
b = A("b")

j.v = b
i.z = b
a.v = j
a.o = d
h.v = j
h.o = a
d.v = b
d.o = h
b.v = j
assert h.o.o.v.v.txt == "j"