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

class B:
    def __init__(self, txt: str):
        self.v: D = None
        self.y: C = None
        self.w: A = None
        self.t: C = None
        self.txt = txt

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

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

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

g = A("g")
a = B("a")
h = C("h")
d = D("d")
m = E("m")
i = E("i")
c = C("c")

g.x = a
a.v = d
a.y = c
a.w = g
a.t = h
h.w = g
h.p = m
d.q = a
d.v = h
d.t = m
m.q = a
m.x = i
m.w = i
m.r = d
i.q = a
i.x = m
i.w = m
i.r = d
c.w = g
c.p = i
assert c.w.x.y.w.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.v: D = None
        self.y: C = None
        self.w: A = None
        self.t: C = None
        self.txt = txt

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

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

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

g = A("g")
a = B("a")
h = C("h")
d = D("d")
m = E("m")
i = E("i")
c = C("c")

g.x = a
a.v = d
a.y = c
a.w = g
a.t = h
h.w = g
h.p = m
d.q = a
d.v = h
d.t = m
m.q = a
m.x = i
m.w = i
m.r = d
i.q = a
i.x = m
i.w = m
i.r = d
c.w = g
c.p = i
assert c.w.x.y.w.x.txt == "a"