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

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

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

l = A("l")
b = B("b")
j = C("j")
g = B("g")
i = C("i")
n = B("n")
e = A("e")
h = A("h")

l.r = i
l.v = h
b.o = n
j.q = i
j.y = g
g.o = b
i.q = j
i.y = n
n.o = b
e.r = i
e.v = l
h.r = j
h.v = l
assert l.r.q.q.y.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.v: A = None
        self.txt = txt

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

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

l = A("l")
b = B("b")
j = C("j")
g = B("g")
i = C("i")
n = B("n")
e = A("e")
h = A("h")

l.r = i
l.v = h
b.o = n
j.q = i
j.y = g
g.o = b
i.q = j
i.y = n
n.o = b
e.r = i
e.v = l
h.r = j
h.v = l
assert l.r.q.q.y.o.o.o.txt == "b"