class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.q: C = None
        self.v: D = None
        self.txt = txt

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

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

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

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

d.o = g
d.q = e
d.v = a
i.w = b
i.y = b
e.r = i
e.o = i
e.x = d
a.y = n
a.u = n
a.x = i
l.y = a
l.x = i
l.u = n
g.o = d
g.q = e
g.v = n
n.y = a
n.x = i
n.u = l
m.r = i
m.o = i
m.x = g
b.r = i
b.o = i
b.x = g
assert i.y.x.q.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.q: C = None
        self.v: D = None
        self.txt = txt

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

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

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

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

d.o = g
d.q = e
d.v = a
i.w = b
i.y = b
e.r = i
e.o = i
e.x = d
a.y = n
a.u = n
a.x = i
l.y = a
l.x = i
l.u = n
g.o = d
g.q = e
g.v = n
n.y = a
n.x = i
n.u = l
m.r = i
m.o = i
m.x = g
b.r = i
b.o = i
b.x = g
assert i.y.x.q.txt == "e"