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

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

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

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

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

n = A("n")
h = B("h")
a = C("a")
f = D("f")
b = E("b")
d = A("d")
g = C("g")

n.w = f
n.s = a
n.r = g
h.r = d
h.x = d
h.p = b
a.y = b
f.y = b
f.u = b
f.v = a
b.p = h
b.r = f
d.w = f
d.s = a
d.r = g
g.y = b
assert a.y.p.p.p.x.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.s: C = None
        self.r: C = None
        self.txt = txt

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

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

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

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

n = A("n")
h = B("h")
a = C("a")
f = D("f")
b = E("b")
d = A("d")
g = C("g")

n.w = f
n.s = a
n.r = g
h.r = d
h.x = d
h.p = b
a.y = b
f.y = b
f.u = b
f.v = a
b.p = h
b.r = f
d.w = f
d.s = a
d.r = g
g.y = b
assert a.y.p.p.p.x.w.txt == "f"