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

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

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

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

class E:
    def __init__(self, txt: str):
        self.v: F = None
        self.txt = txt

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

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

h.p = i
e.u = h
e.p = i
j.y = c
i.z = h
i.u = h
i.w = e
i.x = e
a.v = c
c.o = a
c.r = a
c.w = h
c.p = h
c.s = e
assert e.u.p.z.p.w.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.v: F = None
        self.txt = txt

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

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

h.p = i
e.u = h
e.p = i
j.y = c
i.z = h
i.u = h
i.w = e
i.x = e
a.v = c
c.o = a
c.r = a
c.w = h
c.p = h
c.s = e
assert e.u.p.z.p.w.txt == "e"