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

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

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

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

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

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

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

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

l.z = n
l.v = d
l.r = h
d.o = l
h.q = l
n.o = b
b.z = d
b.v = d
b.r = h
assert l.v.o.v.o.v.txt == "d"