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

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

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

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

class E:
    def __init__(self, txt: str):
        self.x: F = None
        self.o: F = None
        self.y: A = None
        self.txt = txt

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

n = A("n")
h = B("h")
m = C("m")
f = D("f")
a = E("a")
e = F("e")

n.p = a
h.r = a
m.p = h
f.t = n
a.x = e
a.o = e
a.y = n
e.t = h
e.w = h
e.s = h
e.v = f
e.x = m
e.y = n
assert m.p.r.y.p.x.txt == "
class A:
    def __init__(self, txt: str):
        self.p: E = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.x: F = None
        self.o: F = None
        self.y: A = None
        self.txt = txt

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

n = A("n")
h = B("h")
m = C("m")
f = D("f")
a = E("a")
e = F("e")

n.p = a
h.r = a
m.p = h
f.t = n
a.x = e
a.o = e
a.y = n
e.t = h
e.w = h
e.s = h
e.v = f
e.x = m
e.y = n
assert m.p.r.y.p.x.txt == "e"