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

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

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

l = A("l")
b = B("b")
m = C("m")
f = A("f")
g = B("g")
h = C("h")

l.u = g
l.o = f
l.q = m
b.q = h
m.u = b
m.v = h
m.s = g
f.u = b
f.o = l
f.q = m
g.q = m
h.u = g
h.v = m
h.s = b
assert h.u.q.v.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.o: A = None
        self.q: C = None
        self.txt = txt

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

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

l = A("l")
b = B("b")
m = C("m")
f = A("f")
g = B("g")
h = C("h")

l.u = g
l.o = f
l.q = m
b.q = h
m.u = b
m.v = h
m.s = g
f.u = b
f.o = l
f.q = m
g.q = m
h.u = g
h.v = m
h.s = b
assert h.u.q.v.txt == "h"