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

class B:
    def __init__(self, txt: str):
        self.v: B = None
        self.o: D = None
        self.s: D = None
        self.t: C = None
        self.txt = txt

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

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

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

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

class B:
    def __init__(self, txt: str):
        self.v: B = None
        self.o: D = None
        self.s: D = None
        self.t: C = None
        self.txt = txt

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

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

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

e.s = i
e.o = g
e.w = a
g.v = a
g.o = i
g.s = i
g.t = d
d.p = e
i.q = d
a.v = g
a.o = i
a.s = i
a.t = d
b.s = i
b.o = a
b.w = a
j.p = e
assert e.s.q.p.o.txt == "g"