class A:
    def __init__(self, txt: str):
        self.p: E = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.v: B = None
        self.x: C = None
        self.txt = txt

n = A("n")
l = B("l")
j = C("j")
c = D("c")
f = E("f")
g = C("g")
b = C("b")

n.p = f
l.t = f
l.r = j
j.q = c
j.v = c
j.p = g
j.w = l
c.r = l
c.u = l
c.o = n
f.v = l
f.x = j
g.q = c
g.v = c
g.p = j
g.w = l
b.q = c
b.v = c
b.p = g
b.w = l
assert b.w.r.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: E = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.v: B = None
        self.x: C = None
        self.txt = txt

n = A("n")
l = B("l")
j = C("j")
c = D("c")
f = E("f")
g = C("g")
b = C("b")

n.p = f
l.t = f
l.r = j
j.q = c
j.v = c
j.p = g
j.w = l
c.r = l
c.u = l
c.o = n
f.v = l
f.x = j
g.q = c
g.v = c
g.p = j
g.w = l
b.q = c
b.v = c
b.p = g
b.w = l
assert b.w.r.p.txt == "g"