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

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

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

b = A("b")
f = B("f")
a = C("a")
m = C("m")
l = A("l")
k = B("k")
d = A("d")

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

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

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

b = A("b")
f = B("f")
a = C("a")
m = C("m")
l = A("l")
k = B("k")
d = A("d")

b.v = k
b.r = l
f.q = k
f.o = l
f.z = d
a.y = l
m.y = d
l.v = k
l.r = b
k.q = f
k.o = l
k.z = b
d.v = f
d.r = b
assert k.o.r.r.v.txt == "k"