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

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

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

class D:
    def __init__(self, txt: str):
        self.t: A = None
        self.u: E = None
        self.txt = txt

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

c = A("c")
j = B("j")
f = C("f")
h = D("h")
e = E("e")
a = A("a")

c.y = h
c.w = a
j.y = c
j.w = e
j.v = h
j.p = h
j.t = a
f.q = e
f.v = e
f.u = a
f.p = j
h.t = c
h.u = e
e.r = f
a.y = h
a.w = c
assert h.t.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.w: A = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.t: A = None
        self.u: E = None
        self.txt = txt

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

c = A("c")
j = B("j")
f = C("f")
h = D("h")
e = E("e")
a = A("a")

c.y = h
c.w = a
j.y = c
j.w = e
j.v = h
j.p = h
j.t = a
f.q = e
f.v = e
f.u = a
f.p = j
h.t = c
h.u = e
e.r = f
a.y = h
a.w = c
assert h.t.w.w.txt == "c"