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

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

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

g = A("g")
j = B("j")
i = C("i")
d = C("d")
b = A("b")
e = C("e")
k = B("k")
m = C("m")

g.v = j
j.r = g
j.x = d
j.o = k
i.q = b
i.o = k
d.q = b
d.o = j
b.v = k
e.q = g
e.o = j
k.r = b
k.x = i
k.o = j
m.q = b
m.o = k
assert k.o.x.q.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.txt = txt

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

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

g = A("g")
j = B("j")
i = C("i")
d = C("d")
b = A("b")
e = C("e")
k = B("k")
m = C("m")

g.v = j
j.r = g
j.x = d
j.o = k
i.q = b
i.o = k
d.q = b
d.o = j
b.v = k
e.q = g
e.o = j
k.r = b
k.x = i
k.o = j
m.q = b
m.o = k
assert k.o.x.q.v.txt == "k"