class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.u: A = None
        self.txt = txt

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

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

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

e = A("e")
c = B("c")
m = C("m")
n = D("n")
b = D("b")
g = A("g")
a = D("a")
d = B("d")

e.o = c
e.u = g
c.t = d
c.w = d
c.s = a
m.r = g
n.z = e
b.z = g
g.o = d
g.u = e
a.z = g
d.t = c
d.w = c
d.s = a
assert e.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.u: A = None
        self.txt = txt

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

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

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

e = A("e")
c = B("c")
m = C("m")
n = D("n")
b = D("b")
g = A("g")
a = D("a")
d = B("d")

e.o = c
e.u = g
c.t = d
c.w = d
c.s = a
m.r = g
n.z = e
b.z = g
g.o = d
g.u = e
a.z = g
d.t = c
d.w = c
d.s = a
assert e.u.u.u.txt == "g"