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

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

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

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

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

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

b.x = d
d.x = l
g.t = n
g.q = f
g.o = h
g.x = a
n.t = m
a.w = n
m.x = d
j.t = n
j.o = n
j.q = g
j.x = a
l.x = d
f.t = h
f.o = h
f.q = g
f.x = a
h.t = b
assert m.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

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

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

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

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

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

b.x = d
d.x = l
g.t = n
g.q = f
g.o = h
g.x = a
n.t = m
a.w = n
m.x = d
j.t = n
j.o = n
j.q = g
j.x = a
l.x = d
f.t = h
f.o = h
f.q = g
f.x = a
h.t = b
assert m.x.x.x.txt == "d"