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

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

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

j = A("j")
c = B("c")
k = C("k")
a = C("a")
b = C("b")
l = B("l")
h = A("h")
m = C("m")
g = C("g")

j.q = m
j.s = h
j.v = h
c.x = h
k.o = l
a.o = c
b.o = l
l.x = j
h.q = m
h.s = j
h.v = j
m.o = l
g.o = l
assert a.o.x.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.s: A = None
        self.v: A = None
        self.txt = txt

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

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

j = A("j")
c = B("c")
k = C("k")
a = C("a")
b = C("b")
l = B("l")
h = A("h")
m = C("m")
g = C("g")

j.q = m
j.s = h
j.v = h
c.x = h
k.o = l
a.o = c
b.o = l
l.x = j
h.q = m
h.s = j
h.v = j
m.o = l
g.o = l
assert a.o.x.q.txt == "m"