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

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

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

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

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

c.r = g
c.o = g
c.w = g
c.s = a
n.o = d
l.x = j
l.q = a
l.p = g
l.r = d
b.v = l
b.r = d
j.x = a
j.q = a
j.p = g
j.r = k
d.v = l
d.r = b
g.r = c
g.o = c
g.w = c
g.s = a
a.x = j
a.q = j
a.p = g
a.r = k
f.o = d
k.v = a
k.r = b
assert b.v.x.p.o.r.w.o.r.w.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.o: A = None
        self.s: C = None
        self.w: A = None
        self.txt = txt

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

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

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

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

c.r = g
c.o = g
c.w = g
c.s = a
n.o = d
l.x = j
l.q = a
l.p = g
l.r = d
b.v = l
b.r = d
j.x = a
j.q = a
j.p = g
j.r = k
d.v = l
d.r = b
g.r = c
g.o = c
g.w = c
g.s = a
a.x = j
a.q = j
a.p = g
a.r = k
f.o = d
k.v = a
k.r = b
assert b.v.x.p.o.r.w.o.r.w.txt == "g"