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

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

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

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

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

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

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

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

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