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

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

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

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

g = A("g")
m = B("m")
f = C("f")
d = D("d")
l = B("l")
h = D("h")
a = D("a")
n = D("n")
c = C("c")
e = A("e")

g.v = c
g.s = n
g.t = n
m.y = g
m.q = l
m.r = e
m.p = a
f.w = e
f.q = c
d.x = c
l.y = g
l.r = g
l.q = m
l.p = d
h.x = c
a.x = f
n.x = f
c.w = e
c.q = f
e.v = c
e.s = d
e.t = n
assert a.x.q.w.t.x.w.t.x.q.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.s: D = None
        self.t: D = None
        self.txt = txt

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

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

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

g = A("g")
m = B("m")
f = C("f")
d = D("d")
l = B("l")
h = D("h")
a = D("a")
n = D("n")
c = C("c")
e = A("e")

g.v = c
g.s = n
g.t = n
m.y = g
m.q = l
m.r = e
m.p = a
f.w = e
f.q = c
d.x = c
l.y = g
l.r = g
l.q = m
l.p = d
h.x = c
a.x = f
n.x = f
c.w = e
c.q = f
e.v = c
e.s = d
e.t = n
assert a.x.q.w.t.x.w.t.x.q.txt == "c"