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

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

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

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

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

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

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

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

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

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

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