class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.s: C = None
        self.o: D = None
        self.p: D = None
        self.txt = txt

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

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

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

b = A("b")
f = B("f")
g = C("g")
n = D("n")
i = A("i")
l = D("l")
j = C("j")
m = C("m")

b.r = i
b.s = g
b.o = n
b.p = n
f.w = j
g.v = j
g.o = m
n.r = f
n.u = j
i.r = b
i.s = m
i.o = l
i.p = n
l.r = f
l.u = j
j.v = g
j.o = m
m.v = g
m.o = j
assert g.v.v.o.v.v.o.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.s: C = None
        self.o: D = None
        self.p: D = None
        self.txt = txt

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

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

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

b = A("b")
f = B("f")
g = C("g")
n = D("n")
i = A("i")
l = D("l")
j = C("j")
m = C("m")

b.r = i
b.s = g
b.o = n
b.p = n
f.w = j
g.v = j
g.o = m
n.r = f
n.u = j
i.r = b
i.s = m
i.o = l
i.p = n
l.r = f
l.u = j
j.v = g
j.o = m
m.v = g
m.o = j
assert g.v.v.o.v.v.o.txt == "m"