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

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

l = A("l")
b = B("b")
m = B("m")
c = B("c")
h = B("h")
g = B("g")
j = A("j")
e = B("e")

l.v = e
l.u = b
b.o = c
m.o = c
c.o = m
h.o = m
g.o = m
j.v = e
j.u = h
e.o = b
assert l.v.o.o.o.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.u: B = None
        self.txt = txt

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

l = A("l")
b = B("b")
m = B("m")
c = B("c")
h = B("h")
g = B("g")
j = A("j")
e = B("e")

l.v = e
l.u = b
b.o = c
m.o = c
c.o = m
h.o = m
g.o = m
j.v = e
j.u = h
e.o = b
assert l.v.o.o.o.o.o.o.txt == "c"