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

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

class C:
    def __init__(self, txt: str):
        self.q: E = None
        self.txt = txt

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

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

b = A("b")
g = B("g")
k = C("k")
c = D("c")
m = E("m")
d = E("d")
h = C("h")
l = E("l")
f = A("f")

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

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

class C:
    def __init__(self, txt: str):
        self.q: E = None
        self.txt = txt

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

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

b = A("b")
g = B("g")
k = C("k")
c = D("c")
m = E("m")
d = E("d")
h = C("h")
l = E("l")
f = A("f")

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