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

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

class C:
    def __init__(self, txt: str):
        self.x: D = None
        self.txt = txt

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

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

m = A("m")
d = B("d")
h = C("h")
c = D("c")
e = E("e")
f = D("f")
k = A("k")

m.w = c
m.p = k
d.t = f
d.u = f
h.x = f
c.y = f
c.w = f
c.v = d
c.p = k
e.v = f
f.y = c
f.w = c
f.v = d
f.p = m
k.w = c
k.p = m
assert f.y.y.p.p.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.p: A = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.x: D = None
        self.txt = txt

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

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

m = A("m")
d = B("d")
h = C("h")
c = D("c")
e = E("e")
f = D("f")
k = A("k")

m.w = c
m.p = k
d.t = f
d.u = f
h.x = f
c.y = f
c.w = f
c.v = d
c.p = k
e.v = f
f.y = c
f.w = c
f.v = d
f.p = m
k.w = c
k.p = m
assert f.y.y.p.p.w.txt == "c"