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

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

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

k = A("k")
h = B("h")
f = C("f")
b = A("b")
d = A("d")

k.y = h
h.v = d
f.q = h
f.o = b
b.y = h
d.y = h
assert h.v.y.v.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

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

k = A("k")
h = B("h")
f = C("f")
b = A("b")
d = A("d")

k.y = h
h.v = d
f.q = h
f.o = b
b.y = h
d.y = h
assert h.v.y.v.y.txt == "h"