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

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

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

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

j = A("j")
f = B("f")
n = C("n")
d = D("d")
l = A("l")
c = B("c")
m = D("m")
b = A("b")
k = D("k")
i = D("i")

j.x = c
j.o = c
j.r = f
f.v = c
f.r = k
f.x = b
n.w = f
n.p = b
d.w = k
d.u = n
l.x = f
l.r = f
l.o = f
c.v = f
c.r = i
c.x = j
m.w = k
m.u = n
b.x = f
b.r = f
b.o = c
k.w = m
k.u = n
i.w = m
i.u = n
assert l.x.v.r.w.w.u.p.o.r.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.r: B = None
        self.o: B = None
        self.txt = txt

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

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

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

j = A("j")
f = B("f")
n = C("n")
d = D("d")
l = A("l")
c = B("c")
m = D("m")
b = A("b")
k = D("k")
i = D("i")

j.x = c
j.o = c
j.r = f
f.v = c
f.r = k
f.x = b
n.w = f
n.p = b
d.w = k
d.u = n
l.x = f
l.r = f
l.o = f
c.v = f
c.r = i
c.x = j
m.w = k
m.u = n
b.x = f
b.r = f
b.o = c
k.w = m
k.u = n
i.w = m
i.u = n
assert l.x.v.r.w.w.u.p.o.r.txt == "i"