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

class B:
    def __init__(self, txt: str):
        self.r: B = None
        self.q: C = None
        self.w: A = None
        self.txt = txt

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

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

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

f = A("f")
d = B("d")
b = C("b")
i = D("i")
e = E("e")
k = C("k")
m = B("m")

f.p = e
d.r = m
d.q = b
d.w = f
b.r = e
b.u = i
i.u = f
i.p = f
i.y = f
i.z = m
e.y = d
e.u = i
k.r = e
k.u = i
m.r = d
m.q = k
m.w = f
assert m.w.p.u.y.p.y.r.txt == "
class A:
    def __init__(self, txt: str):
        self.p: E = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.r: B = None
        self.q: C = None
        self.w: A = None
        self.txt = txt

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

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

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

f = A("f")
d = B("d")
b = C("b")
i = D("i")
e = E("e")
k = C("k")
m = B("m")

f.p = e
d.r = m
d.q = b
d.w = f
b.r = e
b.u = i
i.u = f
i.p = f
i.y = f
i.z = m
e.y = d
e.u = i
k.r = e
k.u = i
m.r = d
m.q = k
m.w = f
assert m.w.p.u.y.p.y.r.txt == "m"