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

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

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

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

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

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

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

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

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

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

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

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

m.t = f
m.p = n
m.v = b
c.s = h
c.v = f
c.y = b
n.s = d
b.t = n
b.w = n
b.v = h
b.y = h
b.r = f
h.s = m
d.s = h
d.v = f
d.y = b
f.t = m
f.p = n
f.v = b
a.s = f
assert d.s.s.t.txt == "f"