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

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

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

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

e = A("e")
m = B("m")
h = C("h")
c = D("c")
n = C("n")
g = B("g")
k = A("k")
f = C("f")

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

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

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

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

e = A("e")
m = B("m")
h = C("h")
c = D("c")
n = C("n")
g = B("g")
k = A("k")
f = C("f")

e.w = c
m.r = g
m.w = e
m.u = n
m.v = n
h.s = e
h.t = e
c.x = m
c.t = m
n.s = e
n.t = e
g.r = m
g.w = e
g.u = n
g.v = n
k.w = c
f.s = e
f.t = e
assert g.w.w.t.v.t.txt == "e"