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

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

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

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

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

d.s = b
d.o = e
d.z = i
d.u = g
b.s = e
b.u = n
a.o = g
a.p = i
i.p = e
i.q = e
i.x = b
i.o = b
n.s = e
n.u = b
e.s = b
e.o = d
e.z = i
e.u = a
g.o = a
g.p = i
j.p = d
j.q = e
j.x = n
j.o = b
assert d.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.o: A = None
        self.z: D = None
        self.u: C = None
        self.txt = txt

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

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

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

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

d.s = b
d.o = e
d.z = i
d.u = g
b.s = e
b.u = n
a.o = g
a.p = i
i.p = e
i.q = e
i.x = b
i.o = b
n.s = e
n.u = b
e.s = b
e.o = d
e.z = i
e.u = a
g.o = a
g.p = i
j.p = d
j.q = e
j.x = n
j.o = b
assert d.s.s.s.txt == "b"