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

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

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

class D:
    def __init__(self, txt: str):
        self.p: B = None
        self.v: B = None
        self.r: B = None
        self.s: A = None
        self.txt = txt

d = A("d")
f = B("f")
e = C("e")
b = D("b")
j = C("j")
a = D("a")
l = D("l")
i = C("i")
g = C("g")
k = B("k")

d.x = b
d.o = j
f.o = l
f.x = d
e.o = i
e.q = d
e.w = k
b.p = k
b.v = k
b.r = k
b.s = d
j.o = i
j.q = d
j.w = f
a.p = k
a.v = k
a.r = f
a.s = d
l.p = f
l.v = f
l.r = f
l.s = d
i.o = g
i.q = d
i.w = f
g.o = i
g.q = d
g.w = f
k.o = a
k.x = d
assert i.q.o.q.txt == "
class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.o: C = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.p: B = None
        self.v: B = None
        self.r: B = None
        self.s: A = None
        self.txt = txt

d = A("d")
f = B("f")
e = C("e")
b = D("b")
j = C("j")
a = D("a")
l = D("l")
i = C("i")
g = C("g")
k = B("k")

d.x = b
d.o = j
f.o = l
f.x = d
e.o = i
e.q = d
e.w = k
b.p = k
b.v = k
b.r = k
b.s = d
j.o = i
j.q = d
j.w = f
a.p = k
a.v = k
a.r = f
a.s = d
l.p = f
l.v = f
l.r = f
l.s = d
i.o = g
i.q = d
i.w = f
g.o = i
g.q = d
g.w = f
k.o = a
k.x = d
assert i.q.o.q.txt == "d"