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

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

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

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

b = A("b")
k = B("k")
e = C("e")
g = D("g")
l = D("l")
m = A("m")

b.u = m
b.v = e
b.x = k
b.r = g
k.u = l
e.y = g
e.x = l
e.q = k
g.w = l
g.o = e
l.w = g
l.o = e
m.u = b
m.v = e
m.x = k
m.r = g
assert l.o.x.o.x.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.v: C = None
        self.x: B = None
        self.r: D = None
        self.txt = txt

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

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

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

b = A("b")
k = B("k")
e = C("e")
g = D("g")
l = D("l")
m = A("m")

b.u = m
b.v = e
b.x = k
b.r = g
k.u = l
e.y = g
e.x = l
e.q = k
g.w = l
g.o = e
l.w = g
l.o = e
m.u = b
m.v = e
m.x = k
m.r = g
assert l.o.x.o.x.w.w.txt == "l"