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

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

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

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

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

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

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

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

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

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

l.t = d
d.s = g
d.q = l
i.o = d
i.q = j
i.x = n
j.p = d
j.o = l
g.o = d
g.q = n
g.x = n
e.o = d
e.q = n
e.x = j
a.t = d
n.p = d
n.o = a
assert i.o.s.x.p.txt == "d"