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

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

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

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

e = A("e")
d = B("d")
m = C("m")
i = D("i")
f = C("f")
c = A("c")
g = A("g")
j = A("j")

e.u = i
e.p = i
e.t = i
e.q = c
d.p = e
d.q = g
m.x = f
m.o = i
i.w = d
f.x = m
f.o = i
c.u = i
c.p = i
c.t = i
c.q = g
g.u = i
g.p = i
g.t = i
g.q = j
j.u = i
j.p = i
j.t = i
j.q = g
assert c.q.t.w.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.p: D = None
        self.t: D = None
        self.q: A = None
        self.txt = txt

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

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

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

e = A("e")
d = B("d")
m = C("m")
i = D("i")
f = C("f")
c = A("c")
g = A("g")
j = A("j")

e.u = i
e.p = i
e.t = i
e.q = c
d.p = e
d.q = g
m.x = f
m.o = i
i.w = d
f.x = m
f.o = i
c.u = i
c.p = i
c.t = i
c.q = g
g.u = i
g.p = i
g.t = i
g.q = j
j.u = i
j.p = i
j.t = i
j.q = g
assert c.q.t.w.txt == "d"