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

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

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

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

a = A("a")
e = B("e")
i = C("i")
f = D("f")
j = C("j")
h = A("h")
m = B("m")
n = C("n")
g = B("g")

a.t = h
a.x = h
a.p = e
e.v = h
e.s = j
i.x = n
i.q = a
f.q = i
f.r = n
f.s = n
j.x = n
j.q = h
h.t = a
h.x = a
h.p = e
m.v = h
m.s = j
n.x = i
n.q = h
g.v = h
g.s = i
assert a.t.p.s.q.p.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.p: B = None
        self.x: A = None
        self.txt = txt

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

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

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

a = A("a")
e = B("e")
i = C("i")
f = D("f")
j = C("j")
h = A("h")
m = B("m")
n = C("n")
g = B("g")

a.t = h
a.x = h
a.p = e
e.v = h
e.s = j
i.x = n
i.q = a
f.q = i
f.r = n
f.s = n
j.x = n
j.q = h
h.t = a
h.x = a
h.p = e
m.v = h
m.s = j
n.x = i
n.q = h
g.v = h
g.s = i
assert a.t.p.s.q.p.txt == "e"